| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| node-npmtest-jsdom/ | 100% | (147 / 147) | 100% | (122 / 122) | 100% | (26 / 26) | 100% | (147 / 147) | |
| node-npmtest-jsdom/jsdom/lib/ | 17.02% | (40 / 235) | 0% | (0 / 149) | 0% | (0 / 22) | 17.09% | (40 / 234) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/ | 29.59% | (50 / 169) | 3.09% | (3 / 97) | 16% | (4 / 25) | 29.76% | (50 / 168) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/browser/ | 15.7% | (95 / 605) | 0% | (0 / 248) | 0% | (0 / 72) | 15.7% | (95 / 605) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/level2/ | 93.75% | (15 / 16) | 0% | (0 / 2) | 0% | (0 / 2) | 93.75% | (15 / 16) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/level3/ | 9.88% | (110 / 1113) | 0% | (0 / 591) | 1.24% | (2 / 161) | 10.53% | (110 / 1045) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/ | 16.03% | (258 / 1609) | 0.12% | (1 / 806) | 3.9% | (6 / 154) | 16.18% | (258 / 1595) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/attributes/ | 10.34% | (3 / 29) | 0% | (0 / 12) | 0% | (0 / 15) | 10.34% | (3 / 29) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/domparsing/ | 23.81% | (5 / 21) | 0% | (0 / 8) | 0% | (0 / 2) | 23.81% | (5 / 21) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/events/ | 14.06% | (36 / 256) | 0% | (0 / 151) | 0% | (0 / 24) | 14.12% | (36 / 255) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/file-api/ | 11.59% | (16 / 138) | 0% | (0 / 65) | 0% | (0 / 14) | 11.59% | (16 / 138) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/generated/ | 23.35% | (2309 / 9889) | 0.05% | (2 / 4410) | 0.04% | (1 / 2274) | 23.64% | (2309 / 9767) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/helpers/ | 25.32% | (59 / 233) | 0% | (0 / 158) | 0% | (0 / 16) | 25.32% | (59 / 233) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/navigator/ | 58.33% | (21 / 36) | 100% | (0 / 0) | 0% | (0 / 14) | 58.33% | (21 / 36) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/nodes/ | 18.83% | (463 / 2459) | 0% | (0 / 1271) | 0% | (0 / 509) | 18.91% | (463 / 2449) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/traversal/ | 9.68% | (12 / 124) | 0% | (0 / 79) | 0% | (0 / 15) | 9.76% | (12 / 123) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/window/ | 10.45% | (21 / 201) | 0% | (0 / 97) | 0% | (0 / 38) | 10.5% | (21 / 200) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/living/xhr/ | 13.13% | (13 / 99) | 0% | (0 / 74) | 0% | (0 / 9) | 14.13% | (13 / 92) | |
| node-npmtest-jsdom/jsdom/lib/jsdom/web-idl/ | 65.22% | (15 / 23) | 0% | (0 / 4) | 0% | (0 / 1) | 63.64% | (14 / 22) |
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| example.js | 100% | (83 / 83) | 100% | (73 / 73) | 100% | (12 / 12) | 100% | (83 / 83) | |
| lib.npmtest_jsdom.js | 100% | (16 / 16) | 100% | (14 / 14) | 100% | (3 / 3) | 100% | (16 / 16) | |
| test.js | 100% | (48 / 48) | 100% | (35 / 35) | 100% | (11 / 11) | 100% | (48 / 48) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | 2 2 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 2 2 2 2 2 1 2 2 2 1 3 1 1 1 1 1 1 1 1 1 1 1 1 6 6 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /*
example.js
quickstart example
instruction
1. save this script as example.js
2. run the shell command:
$ npm install npmtest-jsdom && PORT=8081 node example.js
3. play with the browser-demo on http://127.0.0.1:8081
*/
/* istanbul instrument in package npmtest_jsdom */
/*jslint
bitwise: true,
browser: true,
maxerr: 8,
maxlen: 96,
node: true,
nomen: true,
regexp: true,
stupid: true
*/
(function () {
'use strict';
var local;
// run shared js-env code - pre-init
(function () {
// init local
local = {};
// init modeJs
local.modeJs = (function () {
try {
return typeof navigator.userAgent === 'string' &&
typeof document.querySelector('body') === 'object' &&
typeof XMLHttpRequest.prototype.open === 'function' &&
'browser';
} catch (errorCaughtBrowser) {
return module.exports &&
typeof process.versions.node === 'string' &&
typeof require('http').createServer === 'function' &&
'node';
}
}());
// init global
local.global = local.modeJs === 'browser'
? window
: global;
// init utility2_rollup
local = local.global.utility2_rollup || (local.modeJs === 'browser'
? local.global.utility2_npmtest_jsdom
: global.utility2_moduleExports);
// export local
local.global.local = local;
}());
switch (local.modeJs) {
// post-init
// run browser js-env code - post-init
/* istanbul ignore next */
case 'browser':
local.testRunBrowser = function (event) {
Eif (!event || (event &&
event.currentTarget &&
event.currentTarget.className &&
event.currentTarget.className.includes &&
event.currentTarget.className.includes('onreset'))) {
// reset output
Array.from(
document.querySelectorAll('body > .resettable')
).forEach(function (element) {
switch (element.tagName) {
case 'INPUT':
case 'TEXTAREA':
element.value = '';
break;
default:
element.textContent = '';
}
});
}
switch (event && event.currentTarget && event.currentTarget.id) {
case 'testRunButton1':
// show tests
Eif (document.querySelector('#testReportDiv1').style.display === 'none') {
document.querySelector('#testReportDiv1').style.display = 'block';
document.querySelector('#testRunButton1').textContent =
'hide internal test';
local.modeTest = true;
local.testRunDefault(local);
// hide tests
} else {
document.querySelector('#testReportDiv1').style.display = 'none';
document.querySelector('#testRunButton1').textContent = 'run internal test';
}
break;
// custom-case
default:
break;
}
Iif (document.querySelector('#inputTextareaEval1') && (!event || (event &&
event.currentTarget &&
event.currentTarget.className &&
event.currentTarget.className.includes &&
event.currentTarget.className.includes('oneval')))) {
// try to eval input-code
try {
/*jslint evil: true*/
eval(document.querySelector('#inputTextareaEval1').value);
} catch (errorCaught) {
console.error(errorCaught.stack);
}
}
};
// log stderr and stdout to #outputTextareaStdout1
['error', 'log'].forEach(function (key) {
console[key + '_original'] = console[key];
console[key] = function () {
var element;
console[key + '_original'].apply(console, arguments);
element = document.querySelector('#outputTextareaStdout1');
Iif (!element) {
return;
}
// append text to #outputTextareaStdout1
element.value += Array.from(arguments).map(function (arg) {
return typeof arg === 'string'
? arg
: JSON.stringify(arg, null, 4);
}).join(' ') + '\n';
// scroll textarea to bottom
element.scrollTop = element.scrollHeight;
};
});
// init event-handling
['change', 'click', 'keyup'].forEach(function (event) {
Array.from(document.querySelectorAll('.on' + event)).forEach(function (element) {
element.addEventListener(event, local.testRunBrowser);
});
});
// run tests
local.testRunBrowser();
break;
// run node js-env code - post-init
/* istanbul ignore next */
case 'node':
// export local
module.exports = local;
// require modules
local.fs = require('fs');
local.http = require('http');
local.url = require('url');
// init assets
local.assetsDict = local.assetsDict || {};
/* jslint-ignore-begin */
local.assetsDict['/assets.index.template.html'] = '\
<!doctype html>\n\
<html lang="en">\n\
<head>\n\
<meta charset="UTF-8">\n\
<meta name="viewport" content="width=device-width, initial-scale=1">\n\
<title>{{env.npm_package_name}} (v{{env.npm_package_version}})</title>\n\
<style>\n\
/*csslint\n\
box-sizing: false,\n\
universal-selector: false\n\
*/\n\
* {\n\
box-sizing: border-box;\n\
}\n\
body {\n\
background: #dde;\n\
font-family: Arial, Helvetica, sans-serif;\n\
margin: 2rem;\n\
}\n\
body > * {\n\
margin-bottom: 1rem;\n\
}\n\
.utility2FooterDiv {\n\
margin-top: 20px;\n\
text-align: center;\n\
}\n\
</style>\n\
<style>\n\
/*csslint\n\
*/\n\
textarea {\n\
font-family: monospace;\n\
height: 10rem;\n\
width: 100%;\n\
}\n\
textarea[readonly] {\n\
background: #ddd;\n\
}\n\
</style>\n\
</head>\n\
<body>\n\
<!-- utility2-comment\n\
<div id="ajaxProgressDiv1" style="background: #d00; height: 2px; left: 0; margin: 0; padding: 0; position: fixed; top: 0; transition: background 0.5s, width 1.5s; width: 25%;"></div>\n\
utility2-comment -->\n\
<h1>\n\
<!-- utility2-comment\n\
<a\n\
{{#if env.npm_package_homepage}}\n\
href="{{env.npm_package_homepage}}"\n\
{{/if env.npm_package_homepage}}\n\
target="_blank"\n\
>\n\
utility2-comment -->\n\
{{env.npm_package_name}} (v{{env.npm_package_version}})\n\
<!-- utility2-comment\n\
</a>\n\
utility2-comment -->\n\
</h1>\n\
<h3>{{env.npm_package_description}}</h3>\n\
<!-- utility2-comment\n\
<h4><a download href="assets.app.js">download standalone app</a></h4>\n\
<button class="onclick onreset" id="testRunButton1">run internal test</button><br>\n\
<div id="testReportDiv1" style="display: none;"></div>\n\
utility2-comment -->\n\
\n\
\n\
\n\
<label>stderr and stdout</label>\n\
<textarea class="resettable" id="outputTextareaStdout1" readonly></textarea>\n\
<!-- utility2-comment\n\
{{#if isRollup}}\n\
<script src="assets.app.js"></script>\n\
{{#unless isRollup}}\n\
utility2-comment -->\n\
<script src="assets.utility2.rollup.js"></script>\n\
<script src="jsonp.utility2._stateInit?callback=window.utility2._stateInit"></script>\n\
<script src="assets.npmtest_jsdom.rollup.js"></script>\n\
<script src="assets.example.js"></script>\n\
<script src="assets.test.js"></script>\n\
<!-- utility2-comment\n\
{{/if isRollup}}\n\
utility2-comment -->\n\
<div class="utility2FooterDiv">\n\
[ this app was created with\n\
<a href="https://github.com/kaizhu256/node-utility2" target="_blank">utility2</a>\n\
]\n\
</div>\n\
</body>\n\
</html>\n\
';
/* jslint-ignore-end */
Iif (local.templateRender) {
local.assetsDict['/'] = local.templateRender(
local.assetsDict['/assets.index.template.html'],
{
env: local.objectSetDefault(local.env, {
npm_package_description: 'the greatest app in the world!',
npm_package_name: 'my-app',
npm_package_nameAlias: 'my_app',
npm_package_version: '0.0.1'
})
}
);
} else {
local.assetsDict['/'] = local.assetsDict['/assets.index.template.html']
.replace((/\{\{env\.(\w+?)\}\}/g), function (match0, match1) {
// jslint-hack
String(match0);
switch (match1) {
case 'npm_package_description':
return 'the greatest app in the world!';
case 'npm_package_name':
return 'my-app';
case 'npm_package_nameAlias':
return 'my_app';
case 'npm_package_version':
return '0.0.1';
}
});
}
// run the cli
Eif (local.global.utility2_rollup || module !== require.main) {
break;
}
local.assetsDict['/assets.example.js'] =
local.assetsDict['/assets.example.js'] ||
local.fs.readFileSync(__filename, 'utf8');
local.assetsDict['/assets.npmtest_jsdom.rollup.js'] =
local.assetsDict['/assets.npmtest_jsdom.rollup.js'] ||
local.fs.readFileSync(
// buildCustomOrg-hack
local.npmtest_jsdom.__dirname +
'/lib.npmtest_jsdom.js',
'utf8'
).replace((/^#!/), '//');
local.assetsDict['/favicon.ico'] = local.assetsDict['/favicon.ico'] || '';
// if $npm_config_timeout_exit exists,
// then exit this process after $npm_config_timeout_exit ms
if (Number(process.env.npm_config_timeout_exit)) {
setTimeout(process.exit, Number(process.env.npm_config_timeout_exit));
}
// start server
if (local.global.utility2_serverHttp1) {
break;
}
process.env.PORT = process.env.PORT || '8081';
console.error('server starting on port ' + process.env.PORT);
local.http.createServer(function (request, response) {
request.urlParsed = local.url.parse(request.url);
if (local.assetsDict[request.urlParsed.pathname] !== undefined) {
response.end(local.assetsDict[request.urlParsed.pathname]);
return;
}
response.statusCode = 404;
response.end();
}).listen(process.env.PORT);
break;
}
}());
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 2 2 2 2 2 2 2 1 2 2 2 2 1 1 1 1 | /* istanbul instrument in package npmtest_jsdom */
/*jslint
bitwise: true,
browser: true,
maxerr: 8,
maxlen: 96,
node: true,
nomen: true,
regexp: true,
stupid: true
*/
(function () {
'use strict';
var local;
// run shared js-env code - pre-init
(function () {
// init local
local = {};
// init modeJs
local.modeJs = (function () {
try {
return typeof navigator.userAgent === 'string' &&
typeof document.querySelector('body') === 'object' &&
typeof XMLHttpRequest.prototype.open === 'function' &&
'browser';
} catch (errorCaughtBrowser) {
return module.exports &&
typeof process.versions.node === 'string' &&
typeof require('http').createServer === 'function' &&
'node';
}
}());
// init global
local.global = local.modeJs === 'browser'
? window
: global;
// init utility2_rollup
local = local.global.utility2_rollup || local;
// init lib
local.local = local.npmtest_jsdom = local;
// init exports
if (local.modeJs === 'browser') {
local.global.utility2_npmtest_jsdom = local;
} else {
module.exports = local;
module.exports.__dirname = __dirname;
module.exports.module = module;
}
}());
}());
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | 2 2 2 2 2 2 2 1 2 2 1 1 1 1 2 2 2 2 1 1 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 2 1 2 2 1 1 1 1 1 | /* istanbul instrument in package npmtest_jsdom */
/*jslint
bitwise: true,
browser: true,
maxerr: 8,
maxlen: 96,
node: true,
nomen: true,
regexp: true,
stupid: true
*/
(function () {
'use strict';
var local;
// run shared js-env code - pre-init
(function () {
// init local
local = {};
// init modeJs
local.modeJs = (function () {
try {
return typeof navigator.userAgent === 'string' &&
typeof document.querySelector('body') === 'object' &&
typeof XMLHttpRequest.prototype.open === 'function' &&
'browser';
} catch (errorCaughtBrowser) {
return module.exports &&
typeof process.versions.node === 'string' &&
typeof require('http').createServer === 'function' &&
'node';
}
}());
// init global
local.global = local.modeJs === 'browser'
? window
: global;
switch (local.modeJs) {
// re-init local from window.local
case 'browser':
local = local.global.utility2.objectSetDefault(
local.global.utility2_rollup || local.global.local,
local.global.utility2
);
break;
// re-init local from example.js
case 'node':
local = (local.global.utility2_rollup || require('utility2'))
.requireExampleJsFromReadme();
break;
}
// export local
local.global.local = local;
}());
// run shared js-env code - function
(function () {
return;
}());
switch (local.modeJs) {
// run browser js-env code - function
case 'browser':
break;
// run node js-env code - function
case 'node':
break;
}
// run shared js-env code - post-init
(function () {
return;
}());
switch (local.modeJs) {
// run browser js-env code - post-init
case 'browser':
// run tests
local.nop(local.modeTest &&
document.querySelector('#testRunButton1') &&
document.querySelector('#testRunButton1').click());
break;
// run node js-env code - post-init
/* istanbul ignore next */
case 'node':
local.testCase_buildApidoc_default = local.testCase_buildApidoc_default || function (
options,
onError
) {
/*
* this function will test buildApidoc's default handling-behavior-behavior
*/
options = { modulePathList: module.paths };
local.buildApidoc(options, onError);
};
local.testCase_buildApp_default = local.testCase_buildApp_default || function (
options,
onError
) {
/*
* this function will test buildApp's default handling-behavior-behavior
*/
local.testCase_buildReadme_default(options, local.onErrorThrow);
local.testCase_buildLib_default(options, local.onErrorThrow);
local.testCase_buildTest_default(options, local.onErrorThrow);
options = [];
local.buildApp(options, onError);
};
local.testCase_buildLib_default = local.testCase_buildLib_default || function (
options,
onError
) {
/*
* this function will test buildLib's default handling-behavior
*/
options = {};
local.buildLib(options, onError);
};
local.testCase_buildReadme_default = local.testCase_buildReadme_default || function (
options,
onError
) {
/*
* this function will test buildReadme's default handling-behavior-behavior
*/
options = {};
local.buildReadme(options, onError);
};
local.testCase_buildTest_default = local.testCase_buildTest_default || function (
options,
onError
) {
/*
* this function will test buildTest's default handling-behavior
*/
options = {};
local.buildTest(options, onError);
};
local.testCase_webpage_default = local.testCase_webpage_default || function (
options,
onError
) {
/*
* this function will test webpage's default handling-behavior
*/
options = { modeCoverageMerge: true, url: local.serverLocalHost + '?modeTest=1' };
local.browserTest(options, onError);
};
// run test-server
local.testRunServer(local);
break;
}
}());
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| jsdom.js | 17.02% | (40 / 235) | 0% | (0 / 149) | 0% | (0 / 22) | 17.09% | (40 / 234) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict"; /* eslint-disable no-unused-expressions */ () => `jsdom 7.x onward only works on Node.js 4 or newer: https://github.com/tmpvar/jsdom#install`; /* eslint-enable no-unused-expressions */ const fs = require("fs"); const path = require("path"); const CookieJar = require("tough-cookie").CookieJar; const parseContentType = require("content-type-parser"); const toFileUrl = require("./jsdom/utils").toFileUrl; const documentFeatures = require("./jsdom/browser/documentfeatures"); const domToHtml = require("./jsdom/browser/domtohtml").domToHtml; const Window = require("./jsdom/browser/Window"); const resourceLoader = require("./jsdom/browser/resource-loader"); const VirtualConsole = require("./jsdom/virtual-console"); const locationInfo = require("./jsdom/living/helpers/internal-constants").locationInfo; const idlUtils = require("./jsdom/living/generated/utils"); const Blob = require("./jsdom/living/generated/Blob"); const whatwgURL = require("whatwg-url"); require("./jsdom/living"); // Enable living standard features /* eslint-disable no-restricted-modules */ // TODO: stop using the built-in URL in favor of the spec-compliant whatwg-url package // This legacy usage is in the process of being purged. const URL = require("url"); /* eslint-enable no-restricted-modules */ const canReadFilesFromFS = Boolean(fs.readFile); // in a browserify environment, this isn't present exports.createVirtualConsole = function (options) { return new VirtualConsole(options); }; exports.getVirtualConsole = function (window) { return window._virtualConsole; }; exports.createCookieJar = function () { return new CookieJar(null, { looseMode: true }); }; exports.nodeLocation = function (node) { return idlUtils.implForWrapper(node)[locationInfo]; }; exports.reconfigureWindow = function (window, newProps) { if ("top" in newProps) { window._top = newProps.top; } }; exports.changeURL = function (window, urlString) { const doc = idlUtils.implForWrapper(window._document); const url = whatwgURL.parseURL(urlString); if (url === "failure") { throw new TypeError(`Could not parse "${urlString}" as a URL`); } doc._URL = url; doc._origin = whatwgURL.serializeURLToUnicodeOrigin(doc._URL); }; // Proxy to features module Object.defineProperty(exports, "defaultDocumentFeatures", { enumerable: true, configurable: true, get() { return documentFeatures.defaultDocumentFeatures; }, set(v) { documentFeatures.defaultDocumentFeatures = v; } }); exports.jsdom = function (html, options) { if (options === undefined) { options = {}; } if (options.parsingMode === undefined || options.parsingMode === "auto") { options.parsingMode = "html"; } if (options.parsingMode !== "html" && options.parsingMode !== "xml") { throw new RangeError(`Invalid parsingMode option ${JSON.stringify(options.parsingMode)}; must be either "html", ` + `"xml", "auto", or undefined`); } options.encoding = options.encoding || "UTF-8"; setGlobalDefaultConfig(options); // Back-compat hack: we have previously suggested nesting these under document, for jsdom.env at least. // So we need to support that. if (options.document) { if (options.document.cookie !== undefined) { options.cookie = options.document.cookie; } if (options.document.referrer !== undefined) { options.referrer = options.document.referrer; } } // List options explicitly to be clear which are passed through const window = new Window({ parsingMode: options.parsingMode, contentType: options.contentType, encoding: options.encoding, parser: options.parser, url: options.url, lastModified: options.lastModified, referrer: options.referrer, cookieJar: options.cookieJar, cookie: options.cookie, resourceLoader: options.resourceLoader, deferClose: options.deferClose, concurrentNodeIterators: options.concurrentNodeIterators, virtualConsole: options.virtualConsole, pool: options.pool, agent: options.agent, agentClass: options.agentClass, agentOptions: options.agentOptions, strictSSL: options.strictSSL, proxy: options.proxy, userAgent: options.userAgent }); const documentImpl = idlUtils.implForWrapper(window.document); documentFeatures.applyDocumentFeatures(documentImpl, options.features); if (options.created) { options.created(null, window.document.defaultView); } if (options.parsingMode === "html") { if (html === undefined || html === "") { html = "<html><head></head><body></body></html>"; } window.document.write(html); } else if (options.parsingMode === "xml") { if (html !== undefined) { documentImpl._htmlToDom.appendHtmlToDocument(html, documentImpl); } } if (window.document.close && !options.deferClose) { window.document.close(); } return window.document; }; exports.jQueryify = exports.jsdom.jQueryify = function (window, jqueryUrl, callback) { if (!window || !window.document) { return; } const implImpl = idlUtils.implForWrapper(window.document.implementation); const features = implImpl._features; implImpl._addFeature("FetchExternalResources", ["script"]); implImpl._addFeature("ProcessExternalResources", ["script"]); const scriptEl = window.document.createElement("script"); scriptEl.className = "jsdom"; scriptEl.src = jqueryUrl; scriptEl.onload = scriptEl.onerror = () => { implImpl._features = features; if (callback) { callback(window, window.jQuery); } }; window.document.body.appendChild(scriptEl); }; exports.env = exports.jsdom.env = function () { const config = getConfigFromArguments(arguments); let req = null; if (config.file && canReadFilesFromFS) { req = resourceLoader.readFile(config.file, { defaultEncoding: config.defaultEncoding, detectMetaCharset: true }, (err, text, res) => { if (err) { reportInitError(err, config); return; } const contentType = parseContentType(res.headers["content-type"]); config.encoding = contentType.get("charset"); setParsingModeFromExtension(config, config.file); config.html = text; processHTML(config); }); } else if (config.html !== undefined) { processHTML(config); } else if (config.url) { req = handleUrl(config); } else if (config.somethingToAutodetect !== undefined) { const url = URL.parse(config.somethingToAutodetect); if (url.protocol && url.hostname) { config.url = config.somethingToAutodetect; req = handleUrl(config.somethingToAutodetect); } else if (canReadFilesFromFS) { req = resourceLoader.readFile(config.somethingToAutodetect, { defaultEncoding: config.defaultEncoding, detectMetaCharset: true }, (err, text, res) => { if (err) { if (err.code === "ENOENT" || err.code === "ENAMETOOLONG") { config.html = config.somethingToAutodetect; processHTML(config); } else { reportInitError(err, config); } } else { const contentType = parseContentType(res.headers["content-type"]); config.encoding = contentType.get("charset"); setParsingModeFromExtension(config, config.somethingToAutodetect); config.html = text; config.url = toFileUrl(config.somethingToAutodetect); processHTML(config); } }); } else { config.html = config.somethingToAutodetect; processHTML(config); } } function handleUrl() { config.cookieJar = config.cookieJar || exports.createCookieJar(); const options = { defaultEncoding: config.defaultEncoding, detectMetaCharset: true, headers: config.headers, pool: config.pool, strictSSL: config.strictSSL, proxy: config.proxy, cookieJar: config.cookieJar, userAgent: config.userAgent, agent: config.agent, agentClass: config.agentClass, agentOptions: config.agentOptions }; const fragment = whatwgURL.parseURL(config.url).fragment; return resourceLoader.download(config.url, options, (err, responseText, res) => { if (err) { reportInitError(err, config); return; } // The use of `res.request.uri.href` ensures that `window.location.href` // is updated when `request` follows redirects. config.html = responseText; config.url = res.request.uri.href; if (fragment) { config.url += `#${fragment}`; } if (res.headers["last-modified"]) { config.lastModified = new Date(res.headers["last-modified"]); } const contentType = parseContentType(res.headers["content-type"]); if (config.parsingMode === "auto") { if (contentType.isXML()) { config.parsingMode = "xml"; } } config.encoding = contentType.get("charset"); processHTML(config); }); } return req; }; exports.serializeDocument = function (doc) { return domToHtml([doc]); }; exports.blobToBuffer = function (blob) { return Blob.is(blob) && idlUtils.implForWrapper(blob)._buffer || undefined; }; exports.evalVMScript = (window, script) => { return script.runInContext(idlUtils.implForWrapper(window._document)._global); }; function processHTML(config) { const window = exports.jsdom(config.html, config).defaultView; const implImpl = idlUtils.implForWrapper(window.document.implementation); const features = JSON.parse(JSON.stringify(implImpl._features)); let docsLoaded = 0; const totalDocs = config.scripts.length + config.src.length; if (!window || !window.document) { reportInitError(new Error("JSDOM: a window object could not be created."), config); return; } function scriptComplete() { docsLoaded++; if (docsLoaded >= totalDocs) { implImpl._features = features; process.nextTick(() => { if (config.onload) { config.onload(window); } if (config.done) { config.done(null, window); } }); } } function handleScriptError() { // nextTick so that an exception within scriptComplete won't cause // another script onerror (which would be an infinite loop) process.nextTick(scriptComplete); } if (config.scripts.length > 0 || config.src.length > 0) { implImpl._addFeature("FetchExternalResources", ["script"]); implImpl._addFeature("ProcessExternalResources", ["script"]); for (const scriptSrc of config.scripts) { const script = window.document.createElement("script"); script.className = "jsdom"; script.onload = scriptComplete; script.onerror = handleScriptError; script.src = scriptSrc; window.document.body.appendChild(script); } for (const scriptText of config.src) { const script = window.document.createElement("script"); script.onload = scriptComplete; script.onerror = handleScriptError; script.text = scriptText; window.document.documentElement.appendChild(script); window.document.documentElement.removeChild(script); } } else if (window.document.readyState === "complete") { scriptComplete(); } else { window.addEventListener("load", scriptComplete); } } function setGlobalDefaultConfig(config) { config.pool = config.pool !== undefined ? config.pool : { maxSockets: 6 }; config.agentOptions = config.agentOptions !== undefined ? config.agentOptions : { keepAlive: true, keepAliveMsecs: 115 * 1000 }; config.strictSSL = config.strictSSL !== undefined ? config.strictSSL : true; config.userAgent = config.userAgent || `Node.js (${process.platform}; U; rv:${process.version}) AppleWebKit/537.36 (KHTML, like Gecko)`; } function getConfigFromArguments(args) { const config = {}; if (typeof args[0] === "object") { Object.assign(config, args[0]); } else { for (const arg of args) { switch (typeof arg) { case "string": config.somethingToAutodetect = arg; break; case "function": config.done = arg; break; case "object": if (Array.isArray(arg)) { config.scripts = arg; } else { Object.assign(config, arg); } break; } } } if (!config.done && !config.created && !config.onload) { throw new Error("Must pass a \"created\", \"onload\", or \"done\" option, or a callback, to jsdom.env"); } if (config.somethingToAutodetect === undefined && config.html === undefined && !config.file && !config.url) { throw new Error("Must pass a \"html\", \"file\", or \"url\" option, or a string, to jsdom.env"); } config.scripts = ensureArray(config.scripts); config.src = ensureArray(config.src); config.parsingMode = config.parsingMode || "auto"; config.features = config.features || { FetchExternalResources: false, ProcessExternalResources: false, SkipExternalResources: false }; if (!config.url && config.file) { config.url = toFileUrl(config.file); } config.defaultEncoding = config.defaultEncoding || "windows-1252"; setGlobalDefaultConfig(config); return config; } function reportInitError(err, config) { if (config.created) { config.created(err); } if (config.done) { config.done(err); } } function ensureArray(value) { let array = value || []; if (typeof array === "string") { array = [array]; } return array; } function setParsingModeFromExtension(config, filename) { if (config.parsingMode === "auto") { const ext = path.extname(filename); if (ext === ".xhtml" || ext === ".xml") { config.parsingMode = "xml"; } } } |
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| named-properties-tracker.js | 16.67% | (9 / 54) | 0% | (0 / 35) | 0% | (0 / 9) | 16.67% | (9 / 54) | |
| utils.js | 38% | (38 / 100) | 5.36% | (3 / 56) | 30.77% | (4 / 13) | 38% | (38 / 100) | |
| virtual-console.js | 20% | (3 / 15) | 0% | (0 / 6) | 0% | (0 / 3) | 21.43% | (3 / 14) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | 1 1 1 1 1 1 1 1 1 | "use strict";
// https://heycam.github.io/webidl/#idl-named-properties
const IS_NAMED_PROPERTY = Symbol();
const TRACKER = Symbol();
/**
* Create a new NamedPropertiesTracker for the given `object`.
*
* Named properties are used in DOM to let you lookup (for example) a Node by accessing a property on another object.
* For example `window.foo` might resolve to an image element with id "foo".
*
* This tracker is a workaround because the ES6 Proxy feature is not yet available.
*
* @param {Object} object
* @param {Function} resolverFunc Each time a property is accessed, this function is called to determine the value of
* the property. The function is passed 3 arguments: (object, name, values).
* `object` is identical to the `object` parameter of this `create` function.
* `name` is the name of the property.
* `values` is a function that returns a Set with all the tracked values for this name. The order of these
* values is undefined.
*
* @returns {NamedPropertiesTracker}
*/
exports.create = function (object, resolverFunc) {
if (object[TRACKER]) {
throw Error("A NamedPropertiesTracker has already been created for this object");
}
const tracker = new NamedPropertiesTracker(object, resolverFunc);
object[TRACKER] = tracker;
return tracker;
};
exports.get = function (object) {
if (!object) {
return null;
}
return object[TRACKER] || null;
};
function NamedPropertiesTracker(object, resolverFunc) {
this.object = object;
this.resolverFunc = resolverFunc;
this.trackedValues = new Map(); // Map<Set<value>>
}
function newPropertyDescriptor(tracker, name) {
const emptySet = new Set();
function getValues() {
return tracker.trackedValues.get(name) || emptySet;
}
const descriptor = {
enumerable: true,
configurable: true,
get() {
return tracker.resolverFunc(tracker.object, name, getValues);
},
set(value) {
Object.defineProperty(tracker.object, name, {
enumerable: true,
configurable: true,
writable: true,
value
});
}
};
descriptor.get[IS_NAMED_PROPERTY] = true;
descriptor.set[IS_NAMED_PROPERTY] = true;
return descriptor;
}
/**
* Track a value (e.g. a Node) for a specified name.
*
* Values can be tracked eagerly, which means that not all tracked values *have* to appear in the output. The resolver
* function that was passed to the output may filter the value.
*
* Tracking the same `name` and `value` pair multiple times has no effect
*
* @param {String} name
* @param {*} value
*/
NamedPropertiesTracker.prototype.track = function (name, value) {
if (name === undefined || name === null || name === "") {
return;
}
let valueSet = this.trackedValues.get(name);
if (!valueSet) {
valueSet = new Set();
this.trackedValues.set(name, valueSet);
}
valueSet.add(value);
if (name in this.object) {
// already added our getter or it is not a named property (e.g. "addEventListener")
return;
}
const descriptor = newPropertyDescriptor(this, name);
Object.defineProperty(this.object, name, descriptor);
};
/**
* Stop tracking a previously tracked `name` & `value` pair, see track().
*
* Untracking the same `name` and `value` pair multiple times has no effect
*
* @param {String} name
* @param {*} value
*/
NamedPropertiesTracker.prototype.untrack = function (name, value) {
if (name === undefined || name === null || name === "") {
return;
}
const valueSet = this.trackedValues.get(name);
if (!valueSet) {
// the value is not present
return;
}
if (!valueSet.delete(value)) {
// the value was not present
return;
}
if (valueSet.size === 0) {
this.trackedValues.delete(name);
}
if (valueSet.size > 0) {
// other values for this name are still present
return;
}
// at this point there are no more values, delete the property
const descriptor = Object.getOwnPropertyDescriptor(this.object, name);
if (!descriptor || !descriptor.get || descriptor.get[IS_NAMED_PROPERTY] !== true) {
// Not defined by NamedPropertyTracker
return;
}
// note: delete puts the object in dictionary mode.
// if this turns out to be a performance issue, maybe add:
// https://github.com/petkaantonov/bluebird/blob/3e36fc861ac5795193ba37935333eb6ef3716390/src/util.js#L177
delete this.object[name];
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | 1 1 1 1 1 1 1 1 6 6 6 1 1 2 37 37 37 1 74 1 1 9 9 9 1 1 1 1 1 1 1 1 1 1 2 2 2 2 | "use strict";
const path = require("path");
const whatwgURL = require("whatwg-url");
const querystring = require("querystring");
const domSymbolTree = require("./living/helpers/internal-constants").domSymbolTree;
const SYMBOL_TREE_POSITION = require("symbol-tree").TreePosition;
const parseURLToResultingURLRecord = require("./living/helpers/document-base-url").parseURLToResultingURLRecord;
exports.toFileUrl = function (fileName) {
// Beyond just the `path.resolve`, this is mostly for the benefit of Windows,
// where we need to convert "\" to "/" and add an extra "/" prefix before the
// drive letter.
let pathname = path.resolve(process.cwd(), fileName).replace(/\\/g, "/");
if (pathname[0] !== "/") {
pathname = "/" + pathname;
}
// path might contain spaces, so convert those to %20
return "file://" + encodeURI(pathname);
};
/**
* Define a getter on an object
*
* This method replaces any existing getter but leaves setters in place.
*
* - `object` {Object} the object to define the getter on
* - `property` {String} the name of the getter
* - `getterFn` {Function} the getter
*/
exports.defineGetter = function defineGetter(object, property, getterFn) {
const descriptor = Object.getOwnPropertyDescriptor(object, property) || {
configurable: true,
enumerable: true
};
descriptor.get = getterFn;
Object.defineProperty(object, property, descriptor);
};
/**
* Define a set of properties on an object, by copying the property descriptors
* from the original object.
*
* - `object` {Object} the target object
* - `properties` {Object} the source from which to copy property descriptors
*/
exports.define = function define(object, properties) {
for (const name of Object.getOwnPropertyNames(properties)) {
const propDesc = Object.getOwnPropertyDescriptor(properties, name);
Object.defineProperty(object, name, propDesc);
}
};
/**
* Define a list of constants on a constructor and its .prototype
*
* - `Constructor` {Function} the constructor to define the constants on
* - `propertyMap` {Object} key/value map of properties to define
*/
exports.addConstants = function addConstants(Constructor, propertyMap) {
for (const property in propertyMap) {
const value = propertyMap[property];
addConstant(Constructor, property, value);
addConstant(Constructor.prototype, property, value);
}
};
function addConstant(object, property, value) {
Object.defineProperty(object, property, {
configurable: false,
enumerable: true,
writable: false,
value
});
}
let memoizeQueryTypeCounter = 0;
/**
* Returns a version of a method that memoizes specific types of calls on the object
*
* - `fn` {Function} the method to be memozied
*/
exports.memoizeQuery = function memoizeQuery(fn) {
// Only memoize query functions with arity <= 2
Iif (fn.length > 2) {
return fn;
}
const type = memoizeQueryTypeCounter++;
return function () {
if (!this._memoizedQueries) {
return fn.apply(this, arguments);
}
if (!this._memoizedQueries[type]) {
this._memoizedQueries[type] = Object.create(null);
}
let key;
if (arguments.length === 1 && typeof arguments[0] === "string") {
key = arguments[0];
} else if (arguments.length === 2 && typeof arguments[0] === "string" && typeof arguments[1] === "string") {
key = arguments[0] + "::" + arguments[1];
} else {
return fn.apply(this, arguments);
}
if (!(key in this._memoizedQueries[type])) {
this._memoizedQueries[type][key] = fn.apply(this, arguments);
}
return this._memoizedQueries[type][key];
};
};
exports.reflectURLAttribute = (elementImpl, contentAttributeName) => {
const attributeValue = elementImpl.getAttribute(contentAttributeName);
if (attributeValue === null || attributeValue === "") {
return "";
}
const urlRecord = parseURLToResultingURLRecord(attributeValue, elementImpl._ownerDocument);
if (urlRecord === "failure") {
return attributeValue;
}
return whatwgURL.serializeURL(urlRecord);
};
function isValidAbsoluteURL(str) {
return whatwgURL.parseURL(str) !== "failure";
}
exports.isValidTargetOrigin = function (str) {
return str === "*" || str === "/" || isValidAbsoluteURL(str);
};
exports.simultaneousIterators = function* (first, second) {
for (;;) {
const firstResult = first.next();
const secondResult = second.next();
if (firstResult.done && secondResult.done) {
return;
}
yield [
firstResult.done ? null : firstResult.value,
secondResult.done ? null : secondResult.value
];
}
};
exports.treeOrderSorter = function (a, b) {
const compare = domSymbolTree.compareTreePosition(a, b);
if (compare & SYMBOL_TREE_POSITION.PRECEDING) { // b is preceding a
return 1;
}
if (compare & SYMBOL_TREE_POSITION.FOLLOWING) {
return -1;
}
// disconnected or equal:
return 0;
};
exports.lengthFromProperties = function (arrayLike) {
let max = -1;
const keys = Object.keys(arrayLike);
const highestKeyIndex = keys.length - 1;
// Abuses a v8 implementation detail for a very fast case
// (if this implementation detail changes, this method will still
// return correct results)
/* eslint-disable eqeqeq */
if (highestKeyIndex == keys[highestKeyIndex]) { // not ===
/* eslint-enable eqeqeq */
return keys.length;
}
for (let i = highestKeyIndex; i >= 0; --i) {
const asNumber = Number(keys[i]);
if (!Number.isNaN(asNumber) && asNumber > max) {
max = asNumber;
}
}
return max + 1;
};
const base64Regexp = /^(?:[A-Z0-9+/]{4})*(?:[A-Z0-9+/]{2}==|[A-Z0-9+/]{3}=|[A-Z0-9+/]{4})$/i;
exports.parseDataUrl = function parseDataUrl(url) {
const urlParts = url.match(/^data:(.+?)(?:;(base64))?,(.*)$/);
let buffer;
if (urlParts[2] === "base64") {
if (urlParts[3] && !base64Regexp.test(urlParts[3])) {
throw new Error("Not a base64 string");
}
buffer = new Buffer(urlParts[3], "base64");
} else {
buffer = new Buffer(querystring.unescape(urlParts[3]));
}
return { buffer, type: urlParts[1] };
};
/* eslint-disable global-require */
exports.Canvas = null;
["canvas", "canvas-prebuilt"].some(moduleName => {
try {
exports.Canvas = require(moduleName);
if (typeof exports.Canvas !== "function") {
// In browserify, the require will succeed but return an empty object
exports.Canvas = null;
}
} catch (e) {
exports.Canvas = null;
}
return exports.Canvas !== null;
});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 1 1 1 | "use strict";
const EventEmitter = require("events").EventEmitter;
module.exports = class VirtualConsole extends EventEmitter {
constructor() {
super();
this.on("error", () => {
// If "error" event has no listeners,
// EventEmitter throws an exception
});
}
sendTo(anyConsole, options) {
if (options === undefined) {
options = {};
}
for (const method of Object.keys(anyConsole)) {
if (typeof anyConsole[method] === "function") {
function onMethodCall() {
anyConsole[method].apply(anyConsole, arguments);
}
this.on(method, onMethodCall);
}
}
if (!options.omitJsdomErrors) {
this.on("jsdomError", e => anyConsole.error(e.stack, e.detail));
}
return this;
}
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| Window.js | 15.95% | (37 / 232) | 0% | (0 / 56) | 0% | (0 / 33) | 15.95% | (37 / 232) | |
| default-stylesheet.js | 100% | (1 / 1) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (1 / 1) | |
| documentAdapter.js | 45.71% | (16 / 35) | 0% | (0 / 10) | 0% | (0 / 15) | 45.71% | (16 / 35) | |
| documentfeatures.js | 14.29% | (3 / 21) | 0% | (0 / 12) | 100% | (0 / 0) | 14.29% | (3 / 21) | |
| domtohtml.js | 50% | (6 / 12) | 0% | (0 / 2) | 0% | (0 / 1) | 50% | (6 / 12) | |
| htmltodom.js | 7.55% | (12 / 159) | 0% | (0 / 96) | 0% | (0 / 10) | 7.55% | (12 / 159) | |
| not-implemented.js | 16.67% | (1 / 6) | 0% | (0 / 2) | 0% | (0 / 1) | 16.67% | (1 / 6) | |
| resource-loader.js | 13.67% | (19 / 139) | 0% | (0 / 70) | 0% | (0 / 12) | 13.67% | (19 / 139) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const webIDLConversions = require("webidl-conversions");
const CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
const notImplemented = require("./not-implemented");
const VirtualConsole = require("../virtual-console");
const define = require("../utils").define;
const EventTarget = require("../living/generated/EventTarget");
const namedPropertiesWindow = require("../living/named-properties-window");
const cssom = require("cssom");
const postMessage = require("../living/post-message");
const DOMException = require("../web-idl/DOMException");
const btoa = require("abab").btoa;
const atob = require("abab").atob;
const idlUtils = require("../living/generated/utils");
const createXMLHttpRequest = require("../living/xmlhttprequest");
const createFileReader = require("../living/generated/FileReader").createInterface;
const Document = require("../living/generated/Document");
const Navigator = require("../living/generated/Navigator");
const reportException = require("../living/helpers/runtime-script-errors");
// NB: the require() must be after assigning `module.exports` because this require() is circular
// TODO: this above note might not even be true anymore... figure out the cycle and document it, or clean up.
module.exports = Window;
const dom = require("../living");
const cssSelectorSplitRE = /((?:[^,"']|"[^"]*"|'[^']*')+)/;
const defaultStyleSheet = cssom.parse(require("./default-stylesheet"));
dom.Window = Window;
// NOTE: per https://heycam.github.io/webidl/#Global, all properties on the Window object must be own-properties.
// That is why we assign everything inside of the constructor, instead of using a shared prototype.
// You can verify this in e.g. Firefox or Internet Explorer, which do a good job with Web IDL compliance.
function Window(options) {
EventTarget.setup(this);
const window = this;
///// INTERFACES FROM THE DOM
// TODO: consider a mode of some sort where these are not shared between all DOM instances
// It'd be very memory-expensive in most cases, though.
for (const name in dom) {
Object.defineProperty(window, name, {
enumerable: false,
configurable: true,
writable: true,
value: dom[name]
});
}
this._core = dom;
///// PRIVATE DATA PROPERTIES
// vm initialization is defered until script processing is activated (in level1/core)
this._globalProxy = this;
this.__timers = Object.create(null);
// Set up the window as if it's a top level window.
// If it's not, then references will be corrected by frame/iframe code.
this._parent = this._top = this._globalProxy;
this._frameElement = null;
// List options explicitly to be clear which are passed through
this._document = Document.create([], {
core: dom,
options: {
parsingMode: options.parsingMode,
contentType: options.contentType,
encoding: options.encoding,
cookieJar: options.cookieJar,
parser: options.parser,
url: options.url,
lastModified: options.lastModified,
referrer: options.referrer,
cookie: options.cookie,
deferClose: options.deferClose,
resourceLoader: options.resourceLoader,
concurrentNodeIterators: options.concurrentNodeIterators,
pool: options.pool,
agent: options.agent,
agentClass: options.agentClass,
agentOptions: options.agentOptions,
strictSSL: options.strictSSL,
proxy: options.proxy,
defaultView: this._globalProxy,
global: this
}
});
// https://html.spec.whatwg.org/#session-history
this._sessionHistory = [{
document: idlUtils.implForWrapper(this._document),
url: idlUtils.implForWrapper(this._document)._URL,
stateObject: null
}];
this._currentSessionHistoryEntryIndex = 0;
// This implements window.frames.length, since window.frames returns a
// self reference to the window object. This value is incremented in the
// HTMLFrameElement init function (see: level2/html.js).
this._length = 0;
if (options.virtualConsole) {
if (options.virtualConsole instanceof VirtualConsole) {
this._virtualConsole = options.virtualConsole;
} else {
throw new TypeError(
"options.virtualConsole must be a VirtualConsole (from createVirtualConsole)");
}
} else {
this._virtualConsole = new VirtualConsole();
}
///// GETTERS
const navigator = Navigator.create([], { userAgent: options.userAgent });
define(this, {
get length() {
return window._length;
},
get window() {
return window._globalProxy;
},
get frameElement() {
return window._frameElement;
},
get frames() {
return window._globalProxy;
},
get self() {
return window._globalProxy;
},
get parent() {
return window._parent;
},
get top() {
return window._top;
},
get document() {
return window._document;
},
get location() {
return idlUtils.wrapperForImpl(idlUtils.implForWrapper(window._document)._location);
},
get history() {
return idlUtils.wrapperForImpl(idlUtils.implForWrapper(window._document)._history);
},
get navigator() {
return navigator;
}
});
namedPropertiesWindow.initializeWindow(this, dom.HTMLCollection);
///// METHODS for [ImplicitThis] hack
// See https://lists.w3.org/Archives/Public/public-script-coord/2015JanMar/0109.html
this.addEventListener = this.addEventListener.bind(this);
this.removeEventListener = this.removeEventListener.bind(this);
this.dispatchEvent = this.dispatchEvent.bind(this);
///// METHODS
let latestTimerId = 0;
this.setTimeout = function (fn, ms) {
const args = [];
for (let i = 2; i < arguments.length; ++i) {
args[i - 2] = arguments[i];
}
return startTimer(window, setTimeout, clearTimeout, ++latestTimerId, fn, ms, args);
};
this.setInterval = function (fn, ms) {
const args = [];
for (let i = 2; i < arguments.length; ++i) {
args[i - 2] = arguments[i];
}
return startTimer(window, setInterval, clearInterval, ++latestTimerId, fn, ms, args);
};
this.clearInterval = stopTimer.bind(this, window);
this.clearTimeout = stopTimer.bind(this, window);
this.__stopAllTimers = stopAllTimers.bind(this, window);
function Option(text, value, defaultSelected, selected) {
if (text === undefined) {
text = "";
}
text = webIDLConversions.DOMString(text);
if (value !== undefined) {
value = webIDLConversions.DOMString(value);
}
defaultSelected = webIDLConversions.boolean(defaultSelected);
selected = webIDLConversions.boolean(selected);
const option = window._document.createElement("option");
const impl = idlUtils.implForWrapper(option);
if (text !== "") {
impl.text = text;
}
if (value !== undefined) {
impl.setAttribute("value", value);
}
if (defaultSelected) {
impl.setAttribute("selected", "");
}
impl._selectedness = selected;
return option;
}
Object.defineProperty(Option, "prototype", {
value: this.HTMLOptionElement.prototype,
configurable: false,
enumerable: false,
writable: false
});
Object.defineProperty(window, "Option", {
value: Option,
configurable: true,
enumerable: false,
writable: true
});
function Image() {
const img = window._document.createElement("img");
const impl = idlUtils.implForWrapper(img);
if (arguments.length > 0) {
impl.setAttribute("width", String(arguments[0]));
}
if (arguments.length > 1) {
impl.setAttribute("height", String(arguments[1]));
}
return img;
}
Object.defineProperty(Image, "prototype", {
value: this.HTMLImageElement.prototype,
configurable: false,
enumerable: false,
writable: false
});
Object.defineProperty(window, "Image", {
value: Image,
configurable: true,
enumerable: false,
writable: true
});
function Audio(src) {
const audio = window._document.createElement("audio");
const impl = idlUtils.implForWrapper(audio);
impl.setAttribute("preload", "auto");
if (src !== undefined) {
impl.setAttribute("src", String(src));
}
return audio;
}
Object.defineProperty(Audio, "prototype", {
value: this.HTMLAudioElement.prototype,
configurable: false,
enumerable: false,
writable: false
});
Object.defineProperty(window, "Audio", {
value: Audio,
configurable: true,
enumerable: false,
writable: true
});
function wrapConsoleMethod(method) {
return function () {
const args = Array.prototype.slice.call(arguments);
window._virtualConsole.emit.apply(window._virtualConsole, [method].concat(args));
};
}
this.postMessage = postMessage;
this.atob = function (str) {
const result = atob(str);
if (result === null) {
throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
"The string to be decoded contains invalid characters.");
}
return result;
};
this.btoa = function (str) {
const result = btoa(str);
if (result === null) {
throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
"The string to be encoded contains invalid characters.");
}
return result;
};
this.FileReader = createFileReader({
window: this
}).interface;
this.XMLHttpRequest = createXMLHttpRequest(this);
// TODO: necessary for Blob and FileReader due to different-globals weirdness; investigate how to avoid this.
this.ArrayBuffer = ArrayBuffer;
this.Int8Array = Int8Array;
this.Uint8Array = Uint8Array;
this.Uint8ClampedArray = Uint8ClampedArray;
this.Int16Array = Int16Array;
this.Uint16Array = Uint16Array;
this.Int32Array = Int32Array;
this.Uint32Array = Uint32Array;
this.Float32Array = Float32Array;
this.Float64Array = Float64Array;
this.stop = function () {
const manager = idlUtils.implForWrapper(this._document)._requestManager;
if (manager) {
manager.close();
}
};
this.close = function () {
// Recursively close child frame windows, then ourselves.
const currentWindow = this;
(function windowCleaner(windowToClean) {
for (let i = 0; i < windowToClean.length; i++) {
windowCleaner(windowToClean[i]);
}
// We"re already in our own window.close().
if (windowToClean !== currentWindow) {
windowToClean.close();
}
}(this));
// Clear out all listeners. Any in-flight or upcoming events should not get delivered.
idlUtils.implForWrapper(this)._eventListeners = Object.create(null);
if (this._document) {
if (this._document.body) {
this._document.body.innerHTML = "";
}
if (this._document.close) {
// It's especially important to clear out the listeners here because document.close() causes a "load" event to
// fire.
idlUtils.implForWrapper(this._document)._eventListeners = Object.create(null);
this._document.close();
}
const doc = idlUtils.implForWrapper(this._document);
if (doc._requestManager) {
doc._requestManager.close();
}
delete this._document;
}
stopAllTimers(currentWindow);
};
this.getComputedStyle = function (node) {
const s = node.style;
const cs = new CSSStyleDeclaration();
const forEach = Array.prototype.forEach;
function setPropertiesFromRule(rule) {
if (!rule.selectorText) {
return;
}
const selectors = rule.selectorText.split(cssSelectorSplitRE);
let matched = false;
for (const selectorText of selectors) {
if (selectorText !== "" && selectorText !== "," && !matched && matchesDontThrow(node, selectorText)) {
matched = true;
forEach.call(rule.style, property => {
cs.setProperty(property, rule.style.getPropertyValue(property), rule.style.getPropertyPriority(property));
});
}
}
}
function readStylesFromStyleSheet(sheet) {
forEach.call(sheet.cssRules, rule => {
if (rule.media) {
if (Array.prototype.indexOf.call(rule.media, "screen") !== -1) {
forEach.call(rule.cssRules, setPropertiesFromRule);
}
} else {
setPropertiesFromRule(rule);
}
});
}
readStylesFromStyleSheet(defaultStyleSheet);
forEach.call(node.ownerDocument.styleSheets, readStylesFromStyleSheet);
forEach.call(s, property => {
cs.setProperty(property, s.getPropertyValue(property), s.getPropertyPriority(property));
});
return cs;
};
///// PUBLIC DATA PROPERTIES (TODO: should be getters)
this.console = {
assert: wrapConsoleMethod("assert"),
clear: wrapConsoleMethod("clear"),
count: wrapConsoleMethod("count"),
debug: wrapConsoleMethod("debug"),
error: wrapConsoleMethod("error"),
group: wrapConsoleMethod("group"),
groupCollapsed: wrapConsoleMethod("groupCollapsed"),
groupEnd: wrapConsoleMethod("groupEnd"),
info: wrapConsoleMethod("info"),
log: wrapConsoleMethod("log"),
table: wrapConsoleMethod("table"),
time: wrapConsoleMethod("time"),
timeEnd: wrapConsoleMethod("timeEnd"),
trace: wrapConsoleMethod("trace"),
warn: wrapConsoleMethod("warn")
};
function notImplementedMethod(name) {
return function () {
notImplemented(name, window);
};
}
define(this, {
name: "nodejs",
innerWidth: 1024,
innerHeight: 768,
outerWidth: 1024,
outerHeight: 768,
pageXOffset: 0,
pageYOffset: 0,
screenX: 0,
screenY: 0,
screenLeft: 0,
screenTop: 0,
scrollX: 0,
scrollY: 0,
scrollTop: 0,
scrollLeft: 0,
screen: {
width: 0,
height: 0
},
alert: notImplementedMethod("window.alert"),
blur: notImplementedMethod("window.blur"),
confirm: notImplementedMethod("window.confirm"),
createPopup: notImplementedMethod("window.createPopup"),
focus: notImplementedMethod("window.focus"),
moveBy: notImplementedMethod("window.moveBy"),
moveTo: notImplementedMethod("window.moveTo"),
open: notImplementedMethod("window.open"),
print: notImplementedMethod("window.print"),
prompt: notImplementedMethod("window.prompt"),
resizeBy: notImplementedMethod("window.resizeBy"),
resizeTo: notImplementedMethod("window.resizeTo"),
scroll: notImplementedMethod("window.scroll"),
scrollBy: notImplementedMethod("window.scrollBy"),
scrollTo: notImplementedMethod("window.scrollTo"),
toString: () => {
return "[object Window]";
}
});
///// INITIALIZATION
process.nextTick(() => {
if (!window.document) {
return; // window might've been closed already
}
if (window.document.readyState === "complete") {
const ev = window.document.createEvent("HTMLEvents");
ev.initEvent("load", false, false);
window.dispatchEvent(ev);
} else {
window.document.addEventListener("load", () => {
const ev = window.document.createEvent("HTMLEvents");
ev.initEvent("load", false, false);
window.dispatchEvent(ev);
});
}
});
}
Object.setPrototypeOf(Window, EventTarget.interface);
Object.setPrototypeOf(Window.prototype, EventTarget.interface.prototype);
function matchesDontThrow(el, selector) {
try {
return el.matches(selector);
} catch (e) {
return false;
}
}
function startTimer(window, startFn, stopFn, timerId, callback, ms, args) {
if (typeof callback !== "function") {
const code = String(callback);
callback = window._globalProxy.eval.bind(window, code + `\n//# sourceURL=${window.location.href}`);
}
const oldCallback = callback;
callback = () => {
try {
oldCallback.apply(window._globalProxy, args);
} catch (e) {
reportException(window, e, window.location.href);
}
};
const res = startFn(callback, ms);
window.__timers[timerId] = [res, stopFn];
return timerId;
}
function stopTimer(window, id) {
const timer = window.__timers[id];
if (timer) {
// Need to .call() with undefined to ensure the thisArg is not timer itself
timer[1].call(undefined, timer[0]);
delete window.__timers[id];
}
}
function stopAllTimers(window) {
Object.keys(window.__timers).forEach(key => {
const timer = window.__timers[key];
// Need to .call() with undefined to ensure the thisArg is not timer itself
timer[1].call(undefined, timer[0]);
});
window.__timers = Object.create(null);
}
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 | 1 | // Ideally, we would use
// https://html.spec.whatwg.org/multipage/rendering.html#the-css-user-agent-style-sheet-and-presentational-hints
// but for now, just use the version from blink. This file is copied from
// https://chromium.googlesource.com/chromium/blink/+/96aa3a280ab7d67178c8f122a04949ce5f8579e0/Source/core/css/html.css
// (removed a line which had octal literals inside since octal literals are not allowed in template strings)
// We use a .js file because otherwise we can't browserify this. (brfs is unusable due to lack of ES2015 support)
module.exports = `
/*
* The default style sheet used to render HTML.
*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
@namespace "http://www.w3.org/1999/xhtml";
html {
display: block
}
:root {
scroll-blocks-on: start-touch wheel-event
}
/* children of the <head> element all have display:none */
head {
display: none
}
meta {
display: none
}
title {
display: none
}
link {
display: none
}
style {
display: none
}
script {
display: none
}
/* generic block-level elements */
body {
display: block;
margin: 8px
}
body:-webkit-full-page-media {
background-color: rgb(0, 0, 0)
}
p {
display: block;
-webkit-margin-before: 1__qem;
-webkit-margin-after: 1__qem;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
}
div {
display: block
}
layer {
display: block
}
article, aside, footer, header, hgroup, main, nav, section {
display: block
}
marquee {
display: inline-block;
}
address {
display: block
}
blockquote {
display: block;
-webkit-margin-before: 1__qem;
-webkit-margin-after: 1em;
-webkit-margin-start: 40px;
-webkit-margin-end: 40px;
}
figcaption {
display: block
}
figure {
display: block;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 40px;
-webkit-margin-end: 40px;
}
q {
display: inline
}
q:before {
content: open-quote;
}
q:after {
content: close-quote;
}
center {
display: block;
/* special centering to be able to emulate the html4/netscape behaviour */
text-align: -webkit-center
}
hr {
display: block;
-webkit-margin-before: 0.5em;
-webkit-margin-after: 0.5em;
-webkit-margin-start: auto;
-webkit-margin-end: auto;
border-style: inset;
border-width: 1px;
box-sizing: border-box
}
map {
display: inline
}
video {
object-fit: contain;
}
/* heading elements */
h1 {
display: block;
font-size: 2em;
-webkit-margin-before: 0.67__qem;
-webkit-margin-after: 0.67em;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
font-weight: bold
}
:-webkit-any(article,aside,nav,section) h1 {
font-size: 1.5em;
-webkit-margin-before: 0.83__qem;
-webkit-margin-after: 0.83em;
}
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1 {
font-size: 1.17em;
-webkit-margin-before: 1__qem;
-webkit-margin-after: 1em;
}
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1 {
font-size: 1.00em;
-webkit-margin-before: 1.33__qem;
-webkit-margin-after: 1.33em;
}
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1 {
font-size: .83em;
-webkit-margin-before: 1.67__qem;
-webkit-margin-after: 1.67em;
}
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1 {
font-size: .67em;
-webkit-margin-before: 2.33__qem;
-webkit-margin-after: 2.33em;
}
h2 {
display: block;
font-size: 1.5em;
-webkit-margin-before: 0.83__qem;
-webkit-margin-after: 0.83em;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
font-weight: bold
}
h3 {
display: block;
font-size: 1.17em;
-webkit-margin-before: 1__qem;
-webkit-margin-after: 1em;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
font-weight: bold
}
h4 {
display: block;
-webkit-margin-before: 1.33__qem;
-webkit-margin-after: 1.33em;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
font-weight: bold
}
h5 {
display: block;
font-size: .83em;
-webkit-margin-before: 1.67__qem;
-webkit-margin-after: 1.67em;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
font-weight: bold
}
h6 {
display: block;
font-size: .67em;
-webkit-margin-before: 2.33__qem;
-webkit-margin-after: 2.33em;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
font-weight: bold
}
/* tables */
table {
display: table;
border-collapse: separate;
border-spacing: 2px;
border-color: gray
}
thead {
display: table-header-group;
vertical-align: middle;
border-color: inherit
}
tbody {
display: table-row-group;
vertical-align: middle;
border-color: inherit
}
tfoot {
display: table-footer-group;
vertical-align: middle;
border-color: inherit
}
/* for tables without table section elements (can happen with XHTML or dynamically created tables) */
table > tr {
vertical-align: middle;
}
col {
display: table-column
}
colgroup {
display: table-column-group
}
tr {
display: table-row;
vertical-align: inherit;
border-color: inherit
}
td, th {
display: table-cell;
vertical-align: inherit
}
th {
font-weight: bold
}
caption {
display: table-caption;
text-align: -webkit-center
}
/* lists */
ul, menu, dir {
display: block;
list-style-type: disc;
-webkit-margin-before: 1__qem;
-webkit-margin-after: 1em;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
-webkit-padding-start: 40px
}
ol {
display: block;
list-style-type: decimal;
-webkit-margin-before: 1__qem;
-webkit-margin-after: 1em;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
-webkit-padding-start: 40px
}
li {
display: list-item;
text-align: -webkit-match-parent;
}
ul ul, ol ul {
list-style-type: circle
}
ol ol ul, ol ul ul, ul ol ul, ul ul ul {
list-style-type: square
}
dd {
display: block;
-webkit-margin-start: 40px
}
dl {
display: block;
-webkit-margin-before: 1__qem;
-webkit-margin-after: 1em;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
}
dt {
display: block
}
ol ul, ul ol, ul ul, ol ol {
-webkit-margin-before: 0;
-webkit-margin-after: 0
}
/* form elements */
form {
display: block;
margin-top: 0__qem;
}
label {
cursor: default;
}
legend {
display: block;
-webkit-padding-start: 2px;
-webkit-padding-end: 2px;
border: none
}
fieldset {
display: block;
-webkit-margin-start: 2px;
-webkit-margin-end: 2px;
-webkit-padding-before: 0.35em;
-webkit-padding-start: 0.75em;
-webkit-padding-end: 0.75em;
-webkit-padding-after: 0.625em;
border: 2px groove ThreeDFace;
min-width: -webkit-min-content;
}
button {
-webkit-appearance: button;
}
/* Form controls don't go vertical. */
input, textarea, keygen, select, button, meter, progress {
-webkit-writing-mode: horizontal-tb !important;
}
input, textarea, keygen, select, button {
margin: 0__qem;
font: -webkit-small-control;
text-rendering: auto; /* FIXME: Remove when tabs work with optimizeLegibility. */
color: initial;
letter-spacing: normal;
word-spacing: normal;
line-height: normal;
text-transform: none;
text-indent: 0;
text-shadow: none;
display: inline-block;
text-align: start;
}
input[type="hidden" i] {
display: none
}
input {
-webkit-appearance: textfield;
padding: 1px;
background-color: white;
border: 2px inset;
-webkit-rtl-ordering: logical;
-webkit-user-select: text;
cursor: auto;
}
input[type="search" i] {
-webkit-appearance: searchfield;
box-sizing: border-box;
}
input::-webkit-textfield-decoration-container {
display: flex;
align-items: center;
-webkit-user-modify: read-only !important;
content: none !important;
}
input[type="search" i]::-webkit-textfield-decoration-container {
direction: ltr;
}
input::-webkit-clear-button {
-webkit-appearance: searchfield-cancel-button;
display: inline-block;
flex: none;
-webkit-user-modify: read-only !important;
-webkit-margin-start: 2px;
opacity: 0;
pointer-events: none;
}
input:enabled:read-write:-webkit-any(:focus,:hover)::-webkit-clear-button {
opacity: 1;
pointer-events: auto;
}
input[type="search" i]::-webkit-search-cancel-button {
-webkit-appearance: searchfield-cancel-button;
display: block;
flex: none;
-webkit-user-modify: read-only !important;
-webkit-margin-start: 1px;
opacity: 0;
pointer-events: none;
}
input[type="search" i]:enabled:read-write:-webkit-any(:focus,:hover)::-webkit-search-cancel-button {
opacity: 1;
pointer-events: auto;
}
input[type="search" i]::-webkit-search-decoration {
-webkit-appearance: searchfield-decoration;
display: block;
flex: none;
-webkit-user-modify: read-only !important;
-webkit-align-self: flex-start;
margin: auto 0;
}
input[type="search" i]::-webkit-search-results-decoration {
-webkit-appearance: searchfield-results-decoration;
display: block;
flex: none;
-webkit-user-modify: read-only !important;
-webkit-align-self: flex-start;
margin: auto 0;
}
input::-webkit-inner-spin-button {
-webkit-appearance: inner-spin-button;
display: inline-block;
cursor: default;
flex: none;
align-self: stretch;
-webkit-user-select: none;
-webkit-user-modify: read-only !important;
opacity: 0;
pointer-events: none;
}
input:enabled:read-write:-webkit-any(:focus,:hover)::-webkit-inner-spin-button {
opacity: 1;
pointer-events: auto;
}
keygen, select {
border-radius: 5px;
}
keygen::-webkit-keygen-select {
margin: 0px;
}
textarea {
-webkit-appearance: textarea;
background-color: white;
border: 1px solid;
-webkit-rtl-ordering: logical;
-webkit-user-select: text;
flex-direction: column;
resize: auto;
cursor: auto;
padding: 2px;
white-space: pre-wrap;
word-wrap: break-word;
}
::-webkit-input-placeholder {
-webkit-text-security: none;
color: darkGray;
display: block !important;
pointer-events: none !important;
}
input::-webkit-input-placeholder {
white-space: pre;
word-wrap: normal;
overflow: hidden;
-webkit-user-modify: read-only !important;
}
input[type="password" i] {
-webkit-text-security: disc !important;
}
input[type="hidden" i], input[type="image" i], input[type="file" i] {
-webkit-appearance: initial;
padding: initial;
background-color: initial;
border: initial;
}
input[type="file" i] {
align-items: baseline;
color: inherit;
text-align: start !important;
}
input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill {
background-color: #FAFFBD !important;
background-image:none !important;
color: #000000 !important;
}
input[type="radio" i], input[type="checkbox" i] {
margin: 3px 0.5ex;
padding: initial;
background-color: initial;
border: initial;
}
input[type="button" i], input[type="submit" i], input[type="reset" i] {
-webkit-appearance: push-button;
-webkit-user-select: none;
white-space: pre
}
input[type="file" i]::-webkit-file-upload-button {
-webkit-appearance: push-button;
-webkit-user-modify: read-only !important;
white-space: nowrap;
margin: 0;
font-size: inherit;
}
input[type="button" i], input[type="submit" i], input[type="reset" i], input[type="file" i]::-webkit-file-upload-button, button {
align-items: flex-start;
text-align: center;
cursor: default;
color: ButtonText;
padding: 2px 6px 3px 6px;
border: 2px outset ButtonFace;
background-color: ButtonFace;
box-sizing: border-box
}
input[type="range" i] {
-webkit-appearance: slider-horizontal;
padding: initial;
border: initial;
margin: 2px;
color: #909090;
}
input[type="range" i]::-webkit-slider-container, input[type="range" i]::-webkit-media-slider-container {
flex: 1;
min-width: 0;
box-sizing: border-box;
-webkit-user-modify: read-only !important;
display: flex;
}
input[type="range" i]::-webkit-slider-runnable-track {
flex: 1;
min-width: 0;
-webkit-align-self: center;
box-sizing: border-box;
-webkit-user-modify: read-only !important;
display: block;
}
input[type="range" i]::-webkit-slider-thumb, input[type="range" i]::-webkit-media-slider-thumb {
-webkit-appearance: sliderthumb-horizontal;
box-sizing: border-box;
-webkit-user-modify: read-only !important;
display: block;
}
input[type="button" i]:disabled, input[type="submit" i]:disabled, input[type="reset" i]:disabled,
input[type="file" i]:disabled::-webkit-file-upload-button, button:disabled,
select:disabled, keygen:disabled, optgroup:disabled, option:disabled,
select[disabled]>option {
color: GrayText
}
input[type="button" i]:active, input[type="submit" i]:active, input[type="reset" i]:active, input[type="file" i]:active::-webkit-file-upload-button, button:active {
border-style: inset
}
input[type="button" i]:active:disabled, input[type="submit" i]:active:disabled, input[type="reset" i]:active:disabled, input[type="file" i]:active:disabled::-webkit-file-upload-button, button:active:disabled {
border-style: outset
}
option:-internal-spatial-navigation-focus {
outline: black dashed 1px;
outline-offset: -1px;
}
datalist {
display: none
}
area {
display: inline;
cursor: pointer;
}
param {
display: none
}
input[type="checkbox" i] {
-webkit-appearance: checkbox;
box-sizing: border-box;
}
input[type="radio" i] {
-webkit-appearance: radio;
box-sizing: border-box;
}
input[type="color" i] {
-webkit-appearance: square-button;
width: 44px;
height: 23px;
background-color: ButtonFace;
/* Same as native_theme_base. */
border: 1px #a9a9a9 solid;
padding: 1px 2px;
}
input[type="color" i]::-webkit-color-swatch-wrapper {
display:flex;
padding: 4px 2px;
box-sizing: border-box;
-webkit-user-modify: read-only !important;
width: 100%;
height: 100%
}
input[type="color" i]::-webkit-color-swatch {
background-color: #000000;
border: 1px solid #777777;
flex: 1;
min-width: 0;
-webkit-user-modify: read-only !important;
}
input[type="color" i][list] {
-webkit-appearance: menulist;
width: 88px;
height: 23px
}
input[type="color" i][list]::-webkit-color-swatch-wrapper {
padding-left: 8px;
padding-right: 24px;
}
input[type="color" i][list]::-webkit-color-swatch {
border-color: #000000;
}
input::-webkit-calendar-picker-indicator {
display: inline-block;
width: 0.66em;
height: 0.66em;
padding: 0.17em 0.34em;
-webkit-user-modify: read-only !important;
opacity: 0;
pointer-events: none;
}
input::-webkit-calendar-picker-indicator:hover {
background-color: #eee;
}
input:enabled:read-write:-webkit-any(:focus,:hover)::-webkit-calendar-picker-indicator,
input::-webkit-calendar-picker-indicator:focus {
opacity: 1;
pointer-events: auto;
}
input[type="date" i]:disabled::-webkit-clear-button,
input[type="date" i]:disabled::-webkit-inner-spin-button,
input[type="datetime-local" i]:disabled::-webkit-clear-button,
input[type="datetime-local" i]:disabled::-webkit-inner-spin-button,
input[type="month" i]:disabled::-webkit-clear-button,
input[type="month" i]:disabled::-webkit-inner-spin-button,
input[type="week" i]:disabled::-webkit-clear-button,
input[type="week" i]:disabled::-webkit-inner-spin-button,
input:disabled::-webkit-calendar-picker-indicator,
input[type="date" i][readonly]::-webkit-clear-button,
input[type="date" i][readonly]::-webkit-inner-spin-button,
input[type="datetime-local" i][readonly]::-webkit-clear-button,
input[type="datetime-local" i][readonly]::-webkit-inner-spin-button,
input[type="month" i][readonly]::-webkit-clear-button,
input[type="month" i][readonly]::-webkit-inner-spin-button,
input[type="week" i][readonly]::-webkit-clear-button,
input[type="week" i][readonly]::-webkit-inner-spin-button,
input[readonly]::-webkit-calendar-picker-indicator {
visibility: hidden;
}
select {
-webkit-appearance: menulist;
box-sizing: border-box;
align-items: center;
border: 1px solid;
white-space: pre;
-webkit-rtl-ordering: logical;
color: black;
background-color: white;
cursor: default;
}
select:not(:-internal-list-box) {
overflow: visible !important;
}
select:-internal-list-box {
-webkit-appearance: listbox;
align-items: flex-start;
border: 1px inset gray;
border-radius: initial;
overflow-x: hidden;
overflow-y: scroll;
vertical-align: text-bottom;
-webkit-user-select: none;
white-space: nowrap;
}
optgroup {
font-weight: bolder;
display: block;
}
option {
font-weight: normal;
display: block;
padding: 0 2px 1px 2px;
white-space: pre;
min-height: 1.2em;
}
select:-internal-list-box option,
select:-internal-list-box optgroup {
line-height: initial !important;
}
select:-internal-list-box:focus option:checked {
background-color: -internal-active-list-box-selection !important;
color: -internal-active-list-box-selection-text !important;
}
select:-internal-list-box option:checked {
background-color: -internal-inactive-list-box-selection !important;
color: -internal-inactive-list-box-selection-text !important;
}
select:-internal-list-box:disabled option:checked,
select:-internal-list-box option:checked:disabled {
color: gray !important;
}
select:-internal-list-box hr {
border-style: none;
}
output {
display: inline;
}
/* meter */
meter {
-webkit-appearance: meter;
box-sizing: border-box;
display: inline-block;
height: 1em;
width: 5em;
vertical-align: -0.2em;
}
meter::-webkit-meter-inner-element {
-webkit-appearance: inherit;
box-sizing: inherit;
-webkit-user-modify: read-only !important;
height: 100%;
width: 100%;
}
meter::-webkit-meter-bar {
background: linear-gradient(to bottom, #ddd, #eee 20%, #ccc 45%, #ccc 55%, #ddd);
height: 100%;
width: 100%;
-webkit-user-modify: read-only !important;
box-sizing: border-box;
}
meter::-webkit-meter-optimum-value {
background: linear-gradient(to bottom, #ad7, #cea 20%, #7a3 45%, #7a3 55%, #ad7);
height: 100%;
-webkit-user-modify: read-only !important;
box-sizing: border-box;
}
meter::-webkit-meter-suboptimum-value {
background: linear-gradient(to bottom, #fe7, #ffc 20%, #db3 45%, #db3 55%, #fe7);
height: 100%;
-webkit-user-modify: read-only !important;
box-sizing: border-box;
}
meter::-webkit-meter-even-less-good-value {
background: linear-gradient(to bottom, #f77, #fcc 20%, #d44 45%, #d44 55%, #f77);
height: 100%;
-webkit-user-modify: read-only !important;
box-sizing: border-box;
}
/* progress */
progress {
-webkit-appearance: progress-bar;
box-sizing: border-box;
display: inline-block;
height: 1em;
width: 10em;
vertical-align: -0.2em;
}
progress::-webkit-progress-inner-element {
-webkit-appearance: inherit;
box-sizing: inherit;
-webkit-user-modify: read-only;
height: 100%;
width: 100%;
}
progress::-webkit-progress-bar {
background-color: gray;
height: 100%;
width: 100%;
-webkit-user-modify: read-only !important;
box-sizing: border-box;
}
progress::-webkit-progress-value {
background-color: green;
height: 100%;
width: 50%; /* should be removed later */
-webkit-user-modify: read-only !important;
box-sizing: border-box;
}
/* inline elements */
u, ins {
text-decoration: underline
}
strong, b {
font-weight: bold
}
i, cite, em, var, address, dfn {
font-style: italic
}
tt, code, kbd, samp {
font-family: monospace
}
pre, xmp, plaintext, listing {
display: block;
font-family: monospace;
white-space: pre;
margin: 1__qem 0
}
mark {
background-color: yellow;
color: black
}
big {
font-size: larger
}
small {
font-size: smaller
}
s, strike, del {
text-decoration: line-through
}
sub {
vertical-align: sub;
font-size: smaller
}
sup {
vertical-align: super;
font-size: smaller
}
nobr {
white-space: nowrap
}
/* states */
:focus {
outline: auto 5px -webkit-focus-ring-color
}
/* Read-only text fields do not show a focus ring but do still receive focus */
html:focus, body:focus, input[readonly]:focus {
outline: none
}
applet:focus, embed:focus, iframe:focus, object:focus {
outline: none
}
input:focus, textarea:focus, keygen:focus, select:focus {
outline-offset: -2px
}
input[type="button" i]:focus,
input[type="checkbox" i]:focus,
input[type="file" i]:focus,
input[type="hidden" i]:focus,
input[type="image" i]:focus,
input[type="radio" i]:focus,
input[type="reset" i]:focus,
input[type="search" i]:focus,
input[type="submit" i]:focus,
input[type="file" i]:focus::-webkit-file-upload-button {
outline-offset: 0
}
a:-webkit-any-link {
color: -webkit-link;
text-decoration: underline;
cursor: auto;
}
a:-webkit-any-link:active {
color: -webkit-activelink
}
/* HTML5 ruby elements */
ruby, rt {
text-indent: 0; /* blocks used for ruby rendering should not trigger this */
}
rt {
line-height: normal;
-webkit-text-emphasis: none;
}
ruby > rt {
display: block;
font-size: 50%;
text-align: start;
}
ruby > rp {
display: none;
}
/* other elements */
noframes {
display: none
}
frameset, frame {
display: block
}
frameset {
border-color: inherit
}
iframe {
border: 2px inset
}
details {
display: block
}
summary {
display: block
}
summary::-webkit-details-marker {
display: inline-block;
width: 0.66em;
height: 0.66em;
-webkit-margin-end: 0.4em;
}
template {
display: none
}
bdi, output {
unicode-bidi: -webkit-isolate;
}
bdo {
unicode-bidi: bidi-override;
}
textarea[dir=auto i] {
unicode-bidi: -webkit-plaintext;
}
dialog:not([open]) {
display: none
}
dialog {
position: absolute;
left: 0;
right: 0;
width: -webkit-fit-content;
height: -webkit-fit-content;
margin: auto;
border: solid;
padding: 1em;
background: white;
color: black
}
dialog::backdrop {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.1)
}
/* page */
@page {
/* FIXME: Define the right default values for page properties. */
size: auto;
margin: auto;
padding: 0px;
border-width: 0px;
}
/* noscript is handled internally, as it depends on settings. */
`;
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const idlUtils = require("../living/generated/utils");
// Tree traversing
exports.getFirstChild = function (node) {
return node.childNodes[0];
};
exports.getChildNodes = function (node) {
// parse5 treats template elements specially, assuming you return an array whose single item is the document fragment
const children = node._templateContents ? [node._templateContents] : [];
if (children.length === 0) {
for (let i = 0; i < node.childNodes.length; ++i) {
children.push(idlUtils.implForWrapper(node.childNodes[i]));
}
}
return children;
};
exports.getParentNode = function (node) {
return node.parentNode;
};
exports.getAttrList = function (node) {
return node.attributes;
};
// Node data
exports.getTagName = function (element) {
return element.tagName.toLowerCase();
};
exports.getNamespaceURI = function (element) {
return element.namespaceURI || "http://www.w3.org/1999/xhtml";
};
exports.getTextNodeContent = function (textNode) {
return textNode.nodeValue;
};
exports.getCommentNodeContent = function (commentNode) {
return commentNode.nodeValue;
};
exports.getDocumentTypeNodeName = function (doctypeNode) {
return doctypeNode.name;
};
exports.getDocumentTypeNodePublicId = function (doctypeNode) {
return doctypeNode.publicId || null;
};
exports.getDocumentTypeNodeSystemId = function (doctypeNode) {
return doctypeNode.systemId || null;
};
// Node types
exports.isTextNode = function (node) {
return node.nodeName === "#text";
};
exports.isCommentNode = function (node) {
return node.nodeName === "#comment";
};
exports.isDocumentTypeNode = function (node) {
return node.nodeType === 10;
};
exports.isElementNode = function (node) {
return Boolean(node.tagName);
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 1 1 1 | "use strict";
exports.availableDocumentFeatures = [
"FetchExternalResources",
"ProcessExternalResources",
"SkipExternalResources"
];
exports.defaultDocumentFeatures = {
FetchExternalResources: ["script", "link"], // omitted by default: "frame"
ProcessExternalResources: ["script"], // omitted by default: "frame", "iframe"
SkipExternalResources: false
};
exports.applyDocumentFeatures = (documentImpl, features) => {
features = features || {};
for (let i = 0; i < exports.availableDocumentFeatures.length; ++i) {
const featureName = exports.availableDocumentFeatures[i];
let featureSource;
if (features[featureName] !== undefined) {
featureSource = features[featureName];
// We have to check the lowercase version also because the Document feature
// methods convert everything to lowercase.
} else if (typeof features[featureName.toLowerCase()] !== "undefined") {
featureSource = features[featureName.toLowerCase()];
} else if (exports.defaultDocumentFeatures[featureName]) {
featureSource = exports.defaultDocumentFeatures[featureName];
} else {
continue;
}
const implImpl = documentImpl._implementation;
implImpl._removeFeature(featureName);
if (featureSource !== undefined) {
if (Array.isArray(featureSource)) {
for (let j = 0; j < featureSource.length; ++j) {
implImpl._addFeature(featureName, featureSource[j]);
}
} else {
implImpl._addFeature(featureName, featureSource);
}
}
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1 1 1 1 1 1 | "use strict";
const parse5 = require("parse5");
const documentAdapter = require("./documentAdapter");
const NODE_TYPE = require("../living/node-type");
const idlUtils = require("../living/generated/utils");
const serializer = new parse5.TreeSerializer(documentAdapter);
exports.domToHtml = function (iterable) {
let ret = "";
for (const node of iterable) {
if (node.nodeType === NODE_TYPE.DOCUMENT_NODE) {
ret += serializer.serialize(node);
} else {
ret += serializer.serialize({ childNodes: [idlUtils.wrapperForImpl(node)] });
}
}
return ret;
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const parse5 = require("parse5");
const sax = require("sax");
const attributes = require("../living/attributes");
const DocumentType = require("../living/generated/DocumentType");
const locationInfo = require("../living/helpers/internal-constants").locationInfo;
class HtmlToDom {
constructor(core, parser, parsingMode) {
if (!parser) {
if (parsingMode === "xml") {
parser = sax;
} else {
parser = parse5;
}
}
this.core = core;
this.parser = parser;
this.parsingMode = parsingMode;
if (parser.DefaultHandler) {
this.parserType = "htmlparser2";
} else if (parser.Parser && parser.TreeAdapters) {
this.parserType = "parse5v1";
} else if (parser.moduleName === "HTML5") {
this.parserType = "html5";
} else if (parser.parser) {
this.parserType = "sax";
}
}
appendHtmlToElement(html, element) {
if (typeof html !== "string") {
html = String(html);
}
return this["_parseWith" + this.parserType](html, true, element);
}
appendHtmlToDocument(html, element) {
if (typeof html !== "string") {
html = String(html);
}
return this["_parseWith" + this.parserType](html, false, element);
}
_parseWithhtmlparser2(html, fragment, element) {
const handler = new this.parser.DefaultHandler();
// Check if document is XML
const isXML = this.parsingMode === "xml";
const parserInstance = new this.parser.Parser(handler, {
xmlMode: isXML,
lowerCaseTags: !isXML,
lowerCaseAttributeNames: !isXML,
decodeEntities: true
});
parserInstance.includeLocation = false;
parserInstance.parseComplete(html);
const parsed = handler.dom;
for (let i = 0; i < parsed.length; i++) {
setChild(this.core, element, parsed[i]);
}
return element;
}
_parseWithparse5v1(html, fragment, element) {
if (this.parsingMode === "xml") {
throw new Error("Can't parse XML with parse5, please use htmlparser2 instead.");
}
const htmlparser2Adapter = this.parser.TreeAdapters.htmlparser2;
let dom;
if (fragment) {
const instance = new this.parser.Parser(htmlparser2Adapter);
const parentElement = htmlparser2Adapter.createElement(element.tagName.toLowerCase(), element.namespaceURI, []);
dom = instance.parseFragment(html, parentElement);
} else {
const instance = new this.parser.Parser(htmlparser2Adapter, { locationInfo: true });
dom = instance.parse(html);
}
const parsed = dom.children;
for (let i = 0; i < parsed.length; i++) {
setChild(this.core, element, parsed[i]);
}
return element;
}
_parseWithhtml5(html, fragment, element) {
if (element.nodeType === 9) {
new this.parser.Parser({ document: element }).parse(html);
} else {
const p = new this.parser.Parser({ document: element.ownerDocument });
p.parse_fragment(html, element);
}
}
_parseWithsax(html, fragment, element) {
const SaxParser = this.parser.parser;
const parser = new SaxParser(/* strict = */true, { xmlns: true });
parser.noscript = false;
parser.looseCase = "toString";
const openStack = [element];
parser.ontext = text => {
setChild(this.core, openStack[openStack.length - 1], {
type: "text",
data: text
});
};
parser.onopentag = arg => {
const attrValues = {};
const attrPrefixes = {};
const attrNamespaces = {};
Object.keys(arg.attributes).forEach(key => {
const localName = arg.attributes[key].local;
attrValues[localName] = arg.attributes[key].value;
attrPrefixes[localName] = arg.attributes[key].prefix || null;
attrNamespaces[localName] = arg.attributes[key].uri || null;
});
if (arg.local === "script" && arg.uri === "http://www.w3.org/1999/xhtml") {
openStack.push({
type: "tag",
name: arg.local,
prefix: arg.prefix,
namespace: arg.uri,
attribs: attrValues,
"x-attribsPrefix": attrPrefixes,
"x-attribsNamespace": attrNamespaces
});
} else {
const elem = setChild(this.core, openStack[openStack.length - 1], {
type: "tag",
name: arg.local,
prefix: arg.prefix,
namespace: arg.uri,
attribs: attrValues,
"x-attribsPrefix": attrPrefixes,
"x-attribsNamespace": attrNamespaces
});
openStack.push(elem);
}
};
parser.onclosetag = () => {
const elem = openStack.pop();
if (elem.constructor.name === "Object") { // we have an empty script tag
setChild(this.core, openStack[openStack.length - 1], elem);
}
};
parser.onscript = scriptText => {
const tag = openStack.pop();
tag.children = [{ type: "text", data: scriptText }];
const elem = setChild(this.core, openStack[openStack.length - 1], tag);
openStack.push(elem);
};
parser.oncomment = comment => {
setChild(this.core, openStack[openStack.length - 1], {
type: "comment",
data: comment
});
};
parser.onprocessinginstruction = pi => {
setChild(this.core, openStack[openStack.length - 1], {
type: "directive",
name: "?" + pi.name,
data: "?" + pi.name + " " + pi.body + "?"
});
};
parser.ondoctype = dt => {
setChild(this.core, openStack[openStack.length - 1], {
type: "directive",
name: "!doctype",
data: "!doctype " + dt
});
const entityMatcher = /<!ENTITY ([^ ]+) "([^"]+)">/g;
let result;
while ((result = entityMatcher.exec(dt))) {
// TODO Node v6 const [, name, value] = result;
const name = result[1];
const value = result[2];
if (!(name in parser.ENTITIES)) {
parser.ENTITIES[name] = value;
}
}
};
parser.onerror = err => {
throw err;
};
parser.write(html).close();
}
}
// utility function for forgiving parser
function setChild(core, parentImpl, node) {
const currentDocument = parentImpl && parentImpl._ownerDocument || parentImpl;
let newNode;
let isTemplateContents = false;
switch (node.type) {
case "tag":
case "script":
case "style":
newNode = currentDocument._createElementWithCorrectElementInterface(node.name, node.namespace);
newNode._prefix = node.prefix || null;
newNode._namespaceURI = node.namespace || null;
break;
case "root":
// If we are in <template> then add all children to the parent's _templateContents; skip this virtual root node.
if (parentImpl.tagName === "TEMPLATE" && parentImpl._namespaceURI === "http://www.w3.org/1999/xhtml") {
newNode = parentImpl._templateContents;
isTemplateContents = true;
}
break;
case "text":
// HTML entities should already be decoded by the parser, so no need to decode them
newNode = currentDocument.createTextNode(node.data);
break;
case "comment":
newNode = currentDocument.createComment(node.data);
break;
case "directive":
if (node.name[0] === "?" && node.name.toLowerCase() !== "?xml") {
const data = node.data.slice(node.name.length + 1, -1);
newNode = currentDocument.createProcessingInstruction(node.name.substring(1), data);
} else if (node.name.toLowerCase() === "!doctype") {
if (node["x-name"] !== undefined) { // parse5 supports doctypes directly
newNode = createDocumentTypeInternal(core, currentDocument,
node["x-name"] || "",
node["x-publicId"] || "",
node["x-systemId"] || "");
} else {
newNode = parseDocType(core, currentDocument, "<" + node.data + ">");
}
}
break;
}
if (!newNode) {
return null;
}
newNode[locationInfo] = node.__location;
if (node.attribs) {
Object.keys(node.attribs).forEach(localName => {
const value = node.attribs[localName];
let prefix =
node["x-attribsPrefix"] &&
Object.prototype.hasOwnProperty.call(node["x-attribsPrefix"], localName) &&
node["x-attribsPrefix"][localName] || null;
const namespace =
node["x-attribsNamespace"] &&
Object.prototype.hasOwnProperty.call(node["x-attribsNamespace"], localName) &&
node["x-attribsNamespace"][localName] || null;
if (prefix === "xmlns" && localName === "") {
// intended weirdness in node-sax, see https://github.com/isaacs/sax-js/issues/165
localName = prefix;
prefix = null;
}
attributes.setAttributeValue(newNode, localName, value, prefix, namespace);
});
}
if (node.children) {
for (let c = 0; c < node.children.length; c++) {
setChild(core, newNode, node.children[c]);
}
}
if (!isTemplateContents) {
if (parentImpl._templateContents) {
// Setting innerHTML on a <template>
parentImpl._templateContents.appendChild(newNode);
} else {
parentImpl.appendChild(newNode);
}
}
return newNode;
}
const HTML5_DOCTYPE = /<!doctype html>/i;
const PUBLIC_DOCTYPE = /<!doctype\s+([^\s]+)\s+public\s+"([^"]+)"\s+"([^"]+)"/i;
const SYSTEM_DOCTYPE = /<!doctype\s+([^\s]+)\s+system\s+"([^"]+)"/i;
function parseDocType(core, doc, html) {
if (HTML5_DOCTYPE.test(html)) {
return createDocumentTypeInternal(core, doc, "html", "", "");
}
const publicPieces = PUBLIC_DOCTYPE.exec(html);
if (publicPieces) {
return createDocumentTypeInternal(core, doc, publicPieces[1], publicPieces[2], publicPieces[3]);
}
const systemPieces = SYSTEM_DOCTYPE.exec(html);
if (systemPieces) {
return createDocumentTypeInternal(core, doc, systemPieces[1], "", systemPieces[2]);
}
// Shouldn't get here (the parser shouldn't let us know about invalid doctypes), but our logic likely isn't
// real-world perfect, so let's fallback.
return createDocumentTypeInternal(core, doc, "html", "", "");
}
function createDocumentTypeInternal(core, ownerDocument, name, publicId, systemId) {
return DocumentType.createImpl([], { core, ownerDocument, name, publicId, systemId });
}
exports.HtmlToDom = HtmlToDom;
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 1 | "use strict"; module.exports = function (nameForErrorMessage, window) { if (!window) { // Do nothing for window-less documents. return; } const error = new Error(`Not implemented: ${nameForErrorMessage}`); error.type = "not implemented"; window._virtualConsole.emit("jsdomError", error); }; |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const parseContentType = require("content-type-parser");
const sniffHTMLEncoding = require("html-encoding-sniffer");
const whatwgEncoding = require("whatwg-encoding");
const parseDataUrl = require("../utils").parseDataUrl;
const fs = require("fs");
const request = require("request");
const documentBaseURLSerialized = require("../living/helpers/document-base-url").documentBaseURLSerialized;
const NODE_TYPE = require("../living/node-type");
/* eslint-disable no-restricted-modules */
// TODO: stop using the built-in URL in favor of the spec-compliant whatwg-url package
// This legacy usage is in the process of being purged.
const URL = require("url");
/* eslint-enable no-restricted-modules */
const IS_BROWSER = Object.prototype.toString.call(process) !== "[object process]";
function createResourceLoadHandler(element, resourceUrl, document, loadCallback) {
if (loadCallback === undefined) {
loadCallback = () => {
// do nothing
};
}
return (err, data, response) => {
const ev = document.createEvent("HTMLEvents");
if (!err) {
try {
loadCallback.call(element, data, resourceUrl, response);
ev.initEvent("load", false, false);
} catch (e) {
err = e;
}
}
if (err) {
if (!err.isAbortError) {
ev.initEvent("error", false, false);
ev.error = err;
element.dispatchEvent(ev);
const error = new Error(`Could not load ${element.localName}: "${resourceUrl}"`);
error.detail = err;
error.type = "resource loading";
document._defaultView._virtualConsole.emit("jsdomError", error);
}
} else {
element.dispatchEvent(ev);
}
};
}
exports.readFile = function (filePath, options, callback) {
const readableStream = fs.createReadStream(filePath);
let data = new Buffer(0);
readableStream.on("error", callback);
readableStream.on("data", chunk => {
data = Buffer.concat([data, chunk]);
});
const defaultEncoding = options.defaultEncoding;
const detectMetaCharset = options.detectMetaCharset;
readableStream.on("end", () => {
// Not passing default encoding means binary
if (defaultEncoding) {
const encoding = detectMetaCharset ? sniffHTMLEncoding(data, { defaultEncoding }) :
whatwgEncoding.getBOMEncoding(data) || defaultEncoding;
const decoded = whatwgEncoding.decode(data, encoding);
callback(null, decoded, { headers: { "content-type": "text/plain;charset=" + encoding } });
} else {
callback(null, data);
}
});
return {
abort() {
readableStream.destroy();
const error = new Error("request canceled by user");
error.isAbortError = true;
callback(error);
}
};
};
function readDataUrl(dataUrl, options, callback) {
const defaultEncoding = options.defaultEncoding;
try {
const data = parseDataUrl(dataUrl);
// If default encoding does not exist, pass on binary data.
if (defaultEncoding) {
const contentType = parseContentType(data.type) || parseContentType("text/plain");
const sniffOptions = {
transportLayerEncodingLabel: contentType.get("charset"),
defaultEncoding
};
const encoding = options.detectMetaCharset ? sniffHTMLEncoding(data.buffer, sniffOptions) :
whatwgEncoding.getBOMEncoding(data.buffer) ||
whatwgEncoding.labelToName(contentType.get("charset")) || defaultEncoding;
const decoded = whatwgEncoding.decode(data.buffer, encoding);
contentType.set("charset", encoding);
data.type = contentType.toString();
callback(null, decoded, { headers: { "content-type": data.type } });
} else {
callback(null, data.buffer, { headers: { "content-type": data.type } });
}
} catch (err) {
callback(err, null);
}
return null;
}
// NOTE: request wraps tough-cookie cookie jar
// (see: https://github.com/request/request/blob/master/lib/cookies.js).
// Therefore, to pass our cookie jar to the request, we need to create
// request's wrapper and monkey patch it with our jar.
function wrapCookieJarForRequest(cookieJar) {
const jarWrapper = request.jar();
jarWrapper._jar = cookieJar;
return jarWrapper;
}
function fetch(urlObj, options, callback) {
if (urlObj.protocol === "data:") {
return readDataUrl(urlObj.href, options, callback);
} else if (urlObj.hostname) {
return exports.download(urlObj, options, callback);
}
const filePath = urlObj.pathname
.replace(/^file:\/\//, "")
.replace(/^\/([a-z]):\//i, "$1:/")
.replace(/%20/g, " ");
return exports.readFile(filePath, options, callback);
}
exports.enqueue = function (element, resourceUrl, callback) {
const document = element.nodeType === NODE_TYPE.DOCUMENT_NODE ? element : element._ownerDocument;
if (document._queue) {
const loadHandler = createResourceLoadHandler(element, resourceUrl || document.URL, document, callback);
return document._queue.push(loadHandler);
}
return () => {
// do nothing in queue-less documents
};
};
exports.download = function (url, options, callback) {
const requestOptions = {
pool: options.pool,
agent: options.agent,
agentOptions: options.agentOptions,
agentClass: options.agentClass,
strictSSL: options.strictSSL,
gzip: true,
jar: wrapCookieJarForRequest(options.cookieJar),
encoding: null,
headers: {
"User-Agent": options.userAgent,
"Accept-Language": "en",
Accept: options.accept || "*/*"
}
};
if (options.referrer && !IS_BROWSER) {
requestOptions.headers.referer = options.referrer;
}
if (options.proxy) {
requestOptions.proxy = options.proxy;
}
Object.assign(requestOptions.headers, options.headers);
const defaultEncoding = options.defaultEncoding;
const detectMetaCharset = options.detectMetaCharset;
const req = request(url, requestOptions, (error, response, bufferData) => {
if (!error) {
// If default encoding does not exist, pass on binary data.
if (defaultEncoding) {
const contentType = parseContentType(response.headers["content-type"]) || parseContentType("text/plain");
const sniffOptions = {
transportLayerEncodingLabel: contentType.get("charset"),
defaultEncoding
};
const encoding = detectMetaCharset ? sniffHTMLEncoding(bufferData, sniffOptions) :
whatwgEncoding.getBOMEncoding(bufferData) ||
whatwgEncoding.labelToName(contentType.get("charset")) || defaultEncoding;
const decoded = whatwgEncoding.decode(bufferData, encoding);
contentType.set("charset", encoding);
response.headers["content-type"] = contentType.toString();
callback(null, decoded, response);
} else {
callback(null, bufferData, response);
}
} else {
callback(error, null, response);
}
});
return {
abort() {
req.abort();
const error = new Error("request canceled by user");
error.isAbortError = true;
callback(error);
}
};
};
exports.load = function (element, urlString, options, callback) {
const document = element._ownerDocument;
const documentImpl = document.implementation;
if (!documentImpl._hasFeature("FetchExternalResources", element.tagName.toLowerCase())) {
return;
}
if (documentImpl._hasFeature("SkipExternalResources", urlString)) {
return;
}
const urlObj = URL.parse(urlString);
const enqueued = exports.enqueue(element, urlString, callback);
const customLoader = document._customResourceLoader;
const requestManager = document._requestManager;
const cookieJar = document._cookieJar;
options.accept = element._accept;
options.cookieJar = cookieJar;
options.referrer = document.URL;
options.pool = document._pool;
options.agentOptions = document._agentOptions;
options.strictSSL = document._strictSSL;
options.proxy = document._proxy;
options.userAgent = document._defaultView.navigator.userAgent;
let req = null;
function wrappedEnqueued() {
if (req && requestManager) {
requestManager.remove(req);
}
// do not trigger if the window is closed
if (element._ownerDocument && element._ownerDocument.defaultView.document) {
enqueued.apply(this, arguments);
}
}
if (typeof customLoader === "function") {
req = customLoader({
element,
url: urlObj,
cookie: cookieJar.getCookieStringSync(urlObj, { http: true }),
baseUrl: documentBaseURLSerialized(document),
defaultFetch(fetchCallback) {
return fetch(urlObj, options, fetchCallback);
}
},
wrappedEnqueued);
} else {
req = fetch(urlObj, options, wrappedEnqueued);
}
if (req && requestManager) {
requestManager.add(req);
}
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| style.js | 93.75% | (15 / 16) | 0% | (0 / 2) | 0% | (0 / 2) | 93.75% | (15 / 16) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const cssom = require("cssom");
const cssstyle = require("cssstyle");
module.exports = core => {
// What works now:
// - Accessing the rules defined in individual stylesheets
// - Modifications to style content attribute are reflected in style property
// - Modifications to style property are reflected in style content attribute
// TODO
// - Modifications to style element's textContent are reflected in sheet property.
// - Modifications to style element's sheet property are reflected in textContent.
// - Modifications to link.href property are reflected in sheet property.
// - Less-used features of link: disabled
// - Less-used features of style: disabled, scoped, title
// - CSSOM-View
// - getComputedStyle(): requires default stylesheet, cascading, inheritance,
// filtering by @media (screen? print?), layout for widths/heights
// - Load events are not in the specs, but apparently some browsers
// implement something. Should onload only fire after all @imports have been
// loaded, or only the primary sheet?
core.StyleSheet = cssom.StyleSheet;
core.MediaList = cssom.MediaList;
core.CSSStyleSheet = cssom.CSSStyleSheet;
core.CSSRule = cssom.CSSRule;
core.CSSStyleRule = cssom.CSSStyleRule;
core.CSSMediaRule = cssom.CSSMediaRule;
core.CSSImportRule = cssom.CSSImportRule;
core.CSSStyleDeclaration = cssstyle.CSSStyleDeclaration;
// Relavant specs
// http://www.w3.org/TR/DOM-Level-2-Style (2000)
// http://www.w3.org/TR/cssom-view/ (2008)
// http://dev.w3.org/csswg/cssom/ (2010) Meant to replace DOM Level 2 Style
// http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML5, of course
// http://dev.w3.org/csswg/css-style-attr/ not sure what's new here
// Objects that aren't in cssom library but should be:
// CSSRuleList (cssom just uses array)
// CSSFontFaceRule
// CSSPageRule
// These rules don't really make sense to implement, so CSSOM draft makes them
// obsolete.
// CSSCharsetRule
// CSSUnknownRule
// These objects are considered obsolete by CSSOM draft, although modern
// browsers implement them.
// CSSValue
// CSSPrimitiveValue
// CSSValueList
// RGBColor
// Rect
// Counter
// http://dev.w3.org/csswg/cssom/#stylesheetlist
function StyleSheetList() {}
StyleSheetList.prototype.__proto__ = Array.prototype;
StyleSheetList.prototype.item = function item(i) {
return Object.prototype.hasOwnProperty.call(this, i) ? this[i] : null;
};
core.StyleSheetList = StyleSheetList;
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| xpath.js | 9.88% | (110 / 1113) | 0% | (0 / 591) | 1.24% | (2 / 161) | 10.53% | (110 / 1045) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 9 1 1 1 1 1 1 1 1 | /** Here is yet another implementation of XPath 1.0 in Javascript.
*
* My goal was to make it relatively compact, but as I fixed all the axis bugs
* the axes became more and more complicated. :-(.
*
* I have not implemented namespaces or case-sensitive axes for XML yet.
*
* How to test it in Chrome: You can make a Chrome extension that replaces
* the WebKit XPath parser with this one. But it takes a bit of effort to
* get around isolated world and same-origin restrictions:
* manifest.json:
{
"name": "XPathTest",
"version": "0.1",
"content_scripts": [{
"matches": ["http://localhost/*"], // or wildcard host
"js": ["xpath.js", "injection.js"],
"all_frames": true, "run_at": "document_start"
}]
}
* injection.js:
// goal: give my xpath object to the website's JS context.
var script = document.createElement('script');
script.textContent =
"document.addEventListener('xpathextend', function(e) {\n" +
" console.log('extending document with xpath...');\n" +
" e.detail(window);" +
"});";
document.documentElement.appendChild(script);
document.documentElement.removeChild(script);
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent('xpathextend', true, true, this.xpath.extend);
document.dispatchEvent(evt);
*/
module.exports = core => {
var xpath = {};
// Helper function to deal with the migration of Attr to no longer have a nodeName property despite this codebase
// assuming it does.
function getNodeName(nodeOrAttr) {
return nodeOrAttr.constructor.name === 'Attr' ? nodeOrAttr.name : nodeOrAttr.nodeName;
}
/***************************************************************************
* Tokenization *
***************************************************************************/
/**
* The XPath lexer is basically a single regular expression, along with
* some helper functions to pop different types.
*/
var Stream = xpath.Stream = function Stream(str) {
this.original = this.str = str;
this.peeked = null;
// TODO: not really needed, but supposedly tokenizer also disambiguates
// a * b vs. node test *
this.prev = null; // for debugging
this.prevprev = null;
}
Stream.prototype = {
peek: function() {
if (this.peeked) return this.peeked;
var m = this.re.exec(this.str);
if (!m) return null;
this.str = this.str.substr(m[0].length);
return this.peeked = m[1];
},
/** Peek 2 tokens ahead. */
peek2: function() {
this.peek(); // make sure this.peeked is set
var m = this.re.exec(this.str);
if (!m) return null;
return m[1];
},
pop: function() {
var r = this.peek();
this.peeked = null;
this.prevprev = this.prev;
this.prev = r;
return r;
},
trypop: function(tokens) {
var tok = this.peek();
if (tok === tokens) return this.pop();
if (Array.isArray(tokens)) {
for (var i = 0; i < tokens.length; ++i) {
var t = tokens[i];
if (t == tok) return this.pop();;
}
}
},
trypopfuncname: function() {
var tok = this.peek();
if (!this.isQnameRe.test(tok))
return null;
switch (tok) {
case 'comment': case 'text': case 'processing-instruction': case 'node':
return null;
}
if ('(' != this.peek2()) return null;
return this.pop();
},
trypopaxisname: function() {
var tok = this.peek();
switch (tok) {
case 'ancestor': case 'ancestor-or-self': case 'attribute':
case 'child': case 'descendant': case 'descendant-or-self':
case 'following': case 'following-sibling': case 'namespace':
case 'parent': case 'preceding': case 'preceding-sibling': case 'self':
if ('::' == this.peek2()) return this.pop();
}
return null;
},
trypopnametest: function() {
var tok = this.peek();
if ('*' === tok || this.startsWithNcNameRe.test(tok)) return this.pop();
return null;
},
trypopliteral: function() {
var tok = this.peek();
if (null == tok) return null;
var first = tok.charAt(0);
var last = tok.charAt(tok.length - 1);
if ('"' === first && '"' === last ||
"'" === first && "'" === last) {
this.pop();
return tok.substr(1, tok.length - 2);
}
},
trypopnumber: function() {
var tok = this.peek();
if (this.isNumberRe.test(tok)) return parseFloat(this.pop());
else return null;
},
trypopvarref: function() {
var tok = this.peek();
if (null == tok) return null;
if ('$' === tok.charAt(0)) return this.pop().substr(1);
else return null;
},
position: function() {
return this.original.length - this.str.length;
}
};
(function() {
// http://www.w3.org/TR/REC-xml-names/#NT-NCName
var nameStartCharsExceptColon =
'A-Z_a-z\xc0-\xd6\xd8-\xf6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF' +
'\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF' +
'\uFDF0-\uFFFD'; // JS doesn't support [#x10000-#xEFFFF]
var nameCharExceptColon = nameStartCharsExceptColon +
'\\-\\.0-9\xb7\u0300-\u036F\u203F-\u2040';
var ncNameChars = '[' + nameStartCharsExceptColon +
'][' + nameCharExceptColon + ']*'
// http://www.w3.org/TR/REC-xml-names/#NT-QName
var qNameChars = ncNameChars + '(?::' + ncNameChars + ')?';
var otherChars = '\\.\\.|[\\(\\)\\[\\].@,]|::'; // .. must come before [.]
var operatorChars =
'and|or|mod|div|' +
'//|!=|<=|>=|[*/|+\\-=<>]'; // //, !=, <=, >= before individual ones.
var literal = '"[^"]*"|' + "'[^']*'";
var numberChars = '[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+';
var variableReference = '\\$' + qNameChars;
var nameTestChars = '\\*|' + ncNameChars + ':\\*|' + qNameChars;
var optionalSpace = '[ \t\r\n]*'; // stricter than regexp \s.
var nodeType = 'comment|text|processing-instruction|node';
var re = new RegExp(
// numberChars before otherChars so that leading-decimal doesn't become .
'^' + optionalSpace + '(' + numberChars + '|' + otherChars + '|' +
nameTestChars + '|' + operatorChars + '|' + literal + '|' +
variableReference + ')'
// operatorName | nodeType | functionName | axisName are lumped into
// qName for now; we'll check them on pop.
);
Stream.prototype.re = re;
Stream.prototype.startsWithNcNameRe = new RegExp('^' + ncNameChars);
Stream.prototype.isQnameRe = new RegExp('^' + qNameChars + '$');
Stream.prototype.isNumberRe = new RegExp('^' + numberChars + '$');
})();
/***************************************************************************
* Parsing *
***************************************************************************/
var parse = xpath.parse = function parse(stream, a) {
var r = orExpr(stream,a);
var x, unparsed = [];
while (x = stream.pop()) {
unparsed.push(x);
}
if (unparsed.length)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Unparsed tokens: ' + unparsed.join(' '));
return r;
}
/**
* binaryL ::= subExpr
* | binaryL op subExpr
* so a op b op c becomes ((a op b) op c)
*/
function binaryL(subExpr, stream, a, ops) {
var lhs = subExpr(stream, a);
if (lhs == null) return null;
var op;
while (op = stream.trypop(ops)) {
var rhs = subExpr(stream, a);
if (rhs == null)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected something after ' + op);
lhs = a.node(op, lhs, rhs);
}
return lhs;
}
/**
* Too bad this is never used. If they made a ** operator (raise to power),
( we would use it.
* binaryR ::= subExpr
* | subExpr op binaryR
* so a op b op c becomes (a op (b op c))
*/
function binaryR(subExpr, stream, a, ops) {
var lhs = subExpr(stream, a);
if (lhs == null) return null;
var op = stream.trypop(ops);
if (op) {
var rhs = binaryR(stream, a);
if (rhs == null)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected something after ' + op);
return a.node(op, lhs, rhs);
} else {
return lhs;// TODO
}
}
/** [1] LocationPath::= RelativeLocationPath | AbsoluteLocationPath
* e.g. a, a/b, //a/b
*/
function locationPath(stream, a) {
return absoluteLocationPath(stream, a) ||
relativeLocationPath(null, stream, a);
}
/** [2] AbsoluteLocationPath::= '/' RelativeLocationPath? | AbbreviatedAbsoluteLocationPath
* [10] AbbreviatedAbsoluteLocationPath::= '//' RelativeLocationPath
*/
function absoluteLocationPath(stream, a) {
var op = stream.peek();
if ('/' === op || '//' === op) {
var lhs = a.node('Root');
return relativeLocationPath(lhs, stream, a, true);
} else {
return null;
}
}
/** [3] RelativeLocationPath::= Step | RelativeLocationPath '/' Step |
* | AbbreviatedRelativeLocationPath
* [11] AbbreviatedRelativeLocationPath::= RelativeLocationPath '//' Step
* e.g. p/a, etc.
*/
function relativeLocationPath(lhs, stream, a, isOnlyRootOk) {
if (null == lhs) {
lhs = step(stream, a);
if (null == lhs) return lhs;
}
var op;
while (op = stream.trypop(['/', '//'])) {
if ('//' === op) {
lhs = a.node('/', lhs,
a.node('Axis', 'descendant-or-self', 'node', undefined));
}
var rhs = step(stream, a);
if (null == rhs && '/' === op && isOnlyRootOk) return lhs;
else isOnlyRootOk = false;
if (null == rhs)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected step after ' + op);
lhs = a.node('/', lhs, rhs);
}
return lhs;
}
/** [4] Step::= AxisSpecifier NodeTest Predicate* | AbbreviatedStep
* [12] AbbreviatedStep::= '.' | '..'
* e.g. @href, self::p, p, a[@href], ., ..
*/
function step(stream, a) {
var abbrStep = stream.trypop(['.', '..']);
if ('.' === abbrStep) // A location step of . is short for self::node().
return a.node('Axis', 'self', 'node');
if ('..' === abbrStep) // A location step of .. is short for parent::node()
return a.node('Axis', 'parent', 'node');
var axis = axisSpecifier(stream, a);
var nodeType = nodeTypeTest(stream, a);
var nodeName;
if (null == nodeType) nodeName = nodeNameTest(stream, a);
if (null == axis && null == nodeType && null == nodeName) return null;
if (null == nodeType && null == nodeName)
throw new XPathException(
XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected nodeTest after axisSpecifier ' + axis);
if (null == axis) axis = 'child';
if (null == nodeType) {
// When there's only a node name, then the node type is forced to be the
// principal node type of the axis.
// see http://www.w3.org/TR/xpath/#dt-principal-node-type
if ('attribute' === axis) nodeType = 'attribute';
else if ('namespace' === axis) nodeType = 'namespace';
else nodeType = 'element';
}
var lhs = a.node('Axis', axis, nodeType, nodeName);
var pred;
while (null != (pred = predicate(lhs, stream, a))) {
lhs = pred;
}
return lhs;
}
/** [5] AxisSpecifier::= AxisName '::' | AbbreviatedAxisSpecifier
* [6] AxisName::= 'ancestor' | 'ancestor-or-self' | 'attribute' | 'child'
* | 'descendant' | 'descendant-or-self' | 'following'
* | 'following-sibling' | 'namespace' | 'parent' |
* | 'preceding' | 'preceding-sibling' | 'self'
* [13] AbbreviatedAxisSpecifier::= '@'?
*/
function axisSpecifier(stream, a) {
var attr = stream.trypop('@');
if (null != attr) return 'attribute';
var axisName = stream.trypopaxisname();
if (null != axisName) {
var coloncolon = stream.trypop('::');
if (null == coloncolon)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Should not happen. Should be ::.');
return axisName;
}
}
/** [7] NodeTest::= NameTest | NodeType '(' ')' | 'processing-instruction' '(' Literal ')'
* [38] NodeType::= 'comment' | 'text' | 'processing-instruction' | 'node'
* I've split nodeTypeTest from nodeNameTest for convenience.
*/
function nodeTypeTest(stream, a) {
if ('(' !== stream.peek2()) {
return null;
}
var type = stream.trypop(['comment', 'text', 'processing-instruction', 'node']);
if (null != type) {
if (null == stream.trypop('('))
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Should not happen.');
var param = undefined;
if (type == 'processing-instruction') {
param = stream.trypopliteral();
}
if (null == stream.trypop(')'))
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected close parens.');
return type
}
}
function nodeNameTest(stream, a) {
var name = stream.trypopnametest();
if (name != null) return name;
else return null;
}
/** [8] Predicate::= '[' PredicateExpr ']'
* [9] PredicateExpr::= Expr
*/
function predicate(lhs, stream, a) {
if (null == stream.trypop('[')) return null;
var expr = orExpr(stream, a);
if (null == expr)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected expression after [');
if (null == stream.trypop(']'))
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected ] after expression.');
return a.node('Predicate', lhs, expr);
}
/** [14] Expr::= OrExpr
*/
/** [15] PrimaryExpr::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall
* e.g. $x, (3+4), "hi", 32, f(x)
*/
function primaryExpr(stream, a) {
var x = stream.trypopliteral();
if (null == x)
x = stream.trypopnumber();
if (null != x) {
return x;
}
var varRef = stream.trypopvarref();
if (null != varRef) return a.node('VariableReference', varRef);
var funCall = functionCall(stream, a);
if (null != funCall) {
return funCall;
}
if (stream.trypop('(')) {
var e = orExpr(stream, a);
if (null == e)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected expression after (.');
if (null == stream.trypop(')'))
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected ) after expression.');
return e;
}
return null;
}
/** [16] FunctionCall::= FunctionName '(' ( Argument ( ',' Argument )* )? ')'
* [17] Argument::= Expr
*/
function functionCall(stream, a) {
var name = stream.trypopfuncname(stream, a);
if (null == name) return null;
if (null == stream.trypop('('))
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected ( ) after function name.');
var params = [];
var first = true;
while (null == stream.trypop(')')) {
if (!first && null == stream.trypop(','))
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected , between arguments of the function.');
first = false;
var param = orExpr(stream, a);
if (param == null)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected expression as argument of function.');
params.push(param);
}
return a.node('FunctionCall', name, params);
}
/** [18] UnionExpr::= PathExpr | UnionExpr '|' PathExpr
*/
function unionExpr(stream, a) { return binaryL(pathExpr, stream, a, '|'); }
/** [19] PathExpr ::= LocationPath
* | FilterExpr
* | FilterExpr '/' RelativeLocationPath
* | FilterExpr '//' RelativeLocationPath
* Unlike most other nodes, this one always generates a node because
* at this point all reverse nodesets must turn into a forward nodeset
*/
function pathExpr(stream, a) {
// We have to do FilterExpr before LocationPath because otherwise
// LocationPath will eat up the name from a function call.
var filter = filterExpr(stream, a);
if (null == filter) {
var loc = locationPath(stream, a);
if (null == loc) {
throw new Error
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': The expression shouldn\'t be empty...');
}
return a.node('PathExpr', loc);
}
var rel = relativeLocationPath(filter, stream, a, false);
if (filter === rel) return rel;
else return a.node('PathExpr', rel);
}
/** [20] FilterExpr::= PrimaryExpr | FilterExpr Predicate
* aka. FilterExpr ::= PrimaryExpr Predicate*
*/
function filterExpr(stream, a) {
var primary = primaryExpr(stream, a);
if (primary == null) return null;
var pred, lhs = primary;
while (null != (pred = predicate(lhs, stream, a))) {
lhs = pred;
}
return lhs;
}
/** [21] OrExpr::= AndExpr | OrExpr 'or' AndExpr
*/
function orExpr(stream, a) {
var orig = (stream.peeked || '') + stream.str
var r = binaryL(andExpr, stream, a, 'or');
var now = (stream.peeked || '') + stream.str;
return r;
}
/** [22] AndExpr::= EqualityExpr | AndExpr 'and' EqualityExpr
*/
function andExpr(stream, a) { return binaryL(equalityExpr, stream, a, 'and'); }
/** [23] EqualityExpr::= RelationalExpr | EqualityExpr '=' RelationalExpr
* | EqualityExpr '!=' RelationalExpr
*/
function equalityExpr(stream, a) { return binaryL(relationalExpr, stream, a, ['=','!=']); }
/** [24] RelationalExpr::= AdditiveExpr | RelationalExpr '<' AdditiveExpr
* | RelationalExpr '>' AdditiveExpr
* | RelationalExpr '<=' AdditiveExpr
* | RelationalExpr '>=' AdditiveExpr
*/
function relationalExpr(stream, a) { return binaryL(additiveExpr, stream, a, ['<','>','<=','>=']); }
/** [25] AdditiveExpr::= MultiplicativeExpr
* | AdditiveExpr '+' MultiplicativeExpr
* | AdditiveExpr '-' MultiplicativeExpr
*/
function additiveExpr(stream, a) { return binaryL(multiplicativeExpr, stream, a, ['+','-']); }
/** [26] MultiplicativeExpr::= UnaryExpr
* | MultiplicativeExpr MultiplyOperator UnaryExpr
* | MultiplicativeExpr 'div' UnaryExpr
* | MultiplicativeExpr 'mod' UnaryExpr
*/
function multiplicativeExpr(stream, a) { return binaryL(unaryExpr, stream, a, ['*','div','mod']); }
/** [27] UnaryExpr::= UnionExpr | '-' UnaryExpr
*/
function unaryExpr(stream, a) {
if (stream.trypop('-')) {
var e = unaryExpr(stream, a);
if (null == e)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Expected unary expression after -');
return a.node('UnaryMinus', e);
}
else return unionExpr(stream, a);
}
var astFactory = {
node: function() {return Array.prototype.slice.call(arguments);}
};
/***************************************************************************
* Optimizations (TODO) *
***************************************************************************/
/**
* Some things I've been considering:
* 1) a//b becomes a/descendant::b if there's no predicate that uses
* position() or last()
* 2) axis[pred]: when pred doesn't use position, evaluate it just once per
* node in the node-set rather than once per (node, position, last).
* For more optimizations, look up Gecko's optimizer:
* http://mxr.mozilla.org/mozilla-central/source/content/xslt/src/xpath/txXPathOptimizer.cpp
*/
// TODO
function optimize(ast) {
}
/***************************************************************************
* Evaluation: axes *
***************************************************************************/
/**
* Data types: For string, number, boolean, we just use Javascript types.
* Node-sets have the form
* {nodes: [node, ...]}
* or {nodes: [node, ...], pos: [[1], [2], ...], lasts: [[1], [2], ...]}
*
* Most of the time, only the node is used and the position information is
* discarded. But if you use a predicate, we need to try every value of
* position and last in case the predicate calls position() or last().
*/
/**
* The NodeMultiSet is a helper class to help generate
* {nodes:[], pos:[], lasts:[]} structures. It is useful for the
* descendant, descendant-or-self, following-sibling, and
* preceding-sibling axes for which we can use a stack to organize things.
*/
function NodeMultiSet(isReverseAxis) {
this.nodes = [];
this.pos = [];
this.lasts = [];
this.nextPos = [];
this.seriesIndexes = []; // index within nodes that each series begins.
this.isReverseAxis = isReverseAxis;
this._pushToNodes = isReverseAxis ? Array.prototype.unshift : Array.prototype.push;
}
NodeMultiSet.prototype = {
pushSeries: function pushSeries() {
this.nextPos.push(1);
this.seriesIndexes.push(this.nodes.length);
},
popSeries: function popSeries() {
console.assert(0 < this.nextPos.length, this.nextPos);
var last = this.nextPos.pop() - 1,
indexInPos = this.nextPos.length,
seriesBeginIndex = this.seriesIndexes.pop(),
seriesEndIndex = this.nodes.length;
for (var i = seriesBeginIndex; i < seriesEndIndex; ++i) {
console.assert(indexInPos < this.lasts[i].length);
console.assert(undefined === this.lasts[i][indexInPos]);
this.lasts[i][indexInPos] = last;
}
},
finalize: function() {
if (null == this.nextPos) return this;
console.assert(0 === this.nextPos.length);
var lastsJSON = JSON.stringify(this.lasts);
for (var i = 0; i < this.lasts.length; ++i) {
for (var j = 0; j < this.lasts[i].length; ++j) {
console.assert(null != this.lasts[i][j], i + ',' + j + ':' + lastsJSON);
}
}
this.pushSeries = this.popSeries = this.addNode = function() {
throw new Error('Already finalized.');
};
return this;
},
addNode: function addNode(node) {
console.assert(node);
this._pushToNodes.call(this.nodes, node)
this._pushToNodes.call(this.pos, this.nextPos.slice());
this._pushToNodes.call(this.lasts, new Array(this.nextPos.length));
for (var i = 0; i < this.nextPos.length; ++i) this.nextPos[i]++;
},
simplify: function() {
this.finalize();
return {nodes:this.nodes, pos:this.pos, lasts:this.lasts};
}
};
function eachContext(nodeMultiSet) {
var r = [];
for (var i = 0; i < nodeMultiSet.nodes.length; i++) {
var node = nodeMultiSet.nodes[i];
if (!nodeMultiSet.pos) {
r.push({nodes:[node], pos: [[i + 1]], lasts: [[nodeMultiSet.nodes.length]]});
} else {
for (var j = 0; j < nodeMultiSet.pos[i].length; ++j) {
r.push({nodes:[node], pos: [[nodeMultiSet.pos[i][j]]], lasts: [[nodeMultiSet.lasts[i][j]]]});
}
}
}
return r;
}
/** Matcher used in the axes.
*/
function NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase) {
this.nodeTypeNum = nodeTypeNum;
this.nodeName = nodeName;
this.shouldLowerCase = shouldLowerCase;
this.nodeNameTest =
null == nodeName ? this._alwaysTrue :
shouldLowerCase ? this._nodeNameLowerCaseEquals :
this._nodeNameEquals;
}
NodeMatcher.prototype = {
matches: function matches(node) {
if (0 === this.nodeTypeNum || this._nodeTypeMatches(node)) {
return this.nodeNameTest(getNodeName(node));
}
return false;
},
_nodeTypeMatches(nodeOrAttr) {
if (nodeOrAttr.constructor.name === 'Attr' && this.nodeTypeNum === 2) {
return true;
}
return nodeOrAttr.nodeType === this.nodeTypeNum;
},
_alwaysTrue: function(name) {return true;},
_nodeNameEquals: function _nodeNameEquals(name) {
return this.nodeName === name;
},
_nodeNameLowerCaseEquals: function _nodeNameLowerCaseEquals(name) {
return this.nodeName === name.toLowerCase();
}
};
function followingSiblingHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, shift, peek, followingNode, andSelf, isReverseAxis) {
var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase);
var nodeMultiSet = new NodeMultiSet(isReverseAxis);
while (0 < nodeList.length) { // can be if for following, preceding
var node = shift.call(nodeList);
console.assert(node != null);
node = followingNode(node);
nodeMultiSet.pushSeries();
var numPushed = 1;
while (null != node) {
if (! andSelf && matcher.matches(node))
nodeMultiSet.addNode(node);
if (node === peek.call(nodeList)) {
shift.call(nodeList);
nodeMultiSet.pushSeries();
numPushed++;
}
if (andSelf && matcher.matches(node))
nodeMultiSet.addNode(node);
node = followingNode(node);
}
while (0 < numPushed--)
nodeMultiSet.popSeries();
}
return nodeMultiSet;
}
/** Returns the next non-descendant node in document order.
* This is the first node in following::node(), if node is the context.
*/
function followingNonDescendantNode(node) {
if (node.ownerElement) {
if (node.ownerElement.firstChild)
return node.ownerElement.firstChild;
node = node.ownerElement;
}
do {
if (node.nextSibling) return node.nextSibling;
} while (node = node.parentNode);
return null;
}
/** Returns the next node in a document-order depth-first search.
* See the definition of document order[1]:
* 1) element
* 2) namespace nodes
* 3) attributes
* 4) children
* [1]: http://www.w3.org/TR/xpath/#dt-document-order
*/
function followingNode(node) {
if (node.ownerElement) // attributes: following node of element.
node = node.ownerElement;
if (null != node.firstChild)
return node.firstChild;
do {
if (null != node.nextSibling) {
return node.nextSibling;
}
node = node.parentNode;
} while (node);
return null;
}
/** Returns the previous node in document order (excluding attributes
* and namespace nodes).
*/
function precedingNode(node) {
if (node.ownerElement)
return node.ownerElement;
if (null != node.previousSibling) {
node = node.previousSibling;
while (null != node.lastChild) {
node = node.lastChild;
}
return node;
}
if (null != node.parentNode) {
return node.parentNode;
}
return null;
}
/** This axis is inefficient if there are many nodes in the nodeList.
* But I think it's a pretty useless axis so it's ok. */
function followingHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase);
var nodeMultiSet = new NodeMultiSet(false);
var cursor = nodeList[0];
var unorderedFollowingStarts = [];
for (var i = 0; i < nodeList.length; i++) {
var node = nodeList[i];
var start = followingNonDescendantNode(node);
if (start)
unorderedFollowingStarts.push(start);
}
if (0 === unorderedFollowingStarts.length)
return {nodes:[]};
var pos = [], nextPos = [];
var started = 0;
while (cursor = followingNode(cursor)) {
for (var i = unorderedFollowingStarts.length - 1; i >= 0; i--){
if (cursor === unorderedFollowingStarts[i]) {
nodeMultiSet.pushSeries();
unorderedFollowingStarts.splice(i,i+1);
started++;
}
}
if (started && matcher.matches(cursor)) {
nodeMultiSet.addNode(cursor);
}
}
console.assert(0 === unorderedFollowingStarts.length);
for (var i = 0; i < started; i++)
nodeMultiSet.popSeries();
return nodeMultiSet.finalize();
}
function precedingHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase);
var cursor = nodeList.pop();
if (null == cursor) return {nodes:{}};
var r = {nodes:[], pos:[], lasts:[]};
var nextParents = [cursor.parentNode || cursor.ownerElement], nextPos = [1];
while (cursor = precedingNode(cursor)) {
if (cursor === nodeList[nodeList.length - 1]) {
nextParents.push(nodeList.pop());
nextPos.push(1);
}
var matches = matcher.matches(cursor);
var pos, someoneUsed = false;
if (matches)
pos = nextPos.slice();
for (var i = 0; i < nextParents.length; ++i) {
if (cursor === nextParents[i]) {
nextParents[i] = cursor.parentNode || cursor.ownerElement;
if (matches) {
pos[i] = null;
}
} else {
if (matches) {
pos[i] = nextPos[i]++;
someoneUsed = true;
}
}
}
if (someoneUsed) {
r.nodes.unshift(cursor);
r.pos.unshift(pos);
}
}
for (var i = 0; i < r.pos.length; ++i) {
var lasts = [];
r.lasts.push(lasts);
for (var j = r.pos[i].length - 1; j >= 0; j--) {
if (null == r.pos[i][j]) {
r.pos[i].splice(j, j+1);
} else {
lasts.unshift(nextPos[j] - 1);
}
}
}
return r;
}
/** node-set, axis -> node-set */
function descendantDfs(nodeMultiSet, node, remaining, matcher, andSelf, attrIndices, attrNodes) {
while (0 < remaining.length && null != remaining[0].ownerElement) {
var attr = remaining.shift();
if (andSelf && matcher.matches(attr)) {
attrNodes.push(attr);
attrIndices.push(nodeMultiSet.nodes.length);
}
}
if (null != node && !andSelf) {
if (matcher.matches(node))
nodeMultiSet.addNode(node);
}
var pushed = false;
if (null == node) {
if (0 === remaining.length) return;
node = remaining.shift();
nodeMultiSet.pushSeries();
pushed = true;
} else if (0 < remaining.length && node === remaining[0]) {
nodeMultiSet.pushSeries();
pushed = true;
remaining.shift();
}
if (andSelf) {
if (matcher.matches(node))
nodeMultiSet.addNode(node);
}
// TODO: use optimization. Also try element.getElementsByTagName
// var nodeList = 1 === nodeTypeNum && null != node.children ? node.children : node.childNodes;
var nodeList = node.childNodes;
for (var j = 0; j < nodeList.length; ++j) {
var child = nodeList[j];
descendantDfs(nodeMultiSet, child, remaining, matcher, andSelf, attrIndices, attrNodes);
}
if (pushed) {
nodeMultiSet.popSeries();
}
}
function descenantHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, andSelf) {
var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase);
var nodeMultiSet = new NodeMultiSet(false);
var attrIndices = [], attrNodes = [];
while (0 < nodeList.length) {
// var node = nodeList.shift();
descendantDfs(nodeMultiSet, null, nodeList, matcher, andSelf, attrIndices, attrNodes);
}
nodeMultiSet.finalize();
for (var i = attrNodes.length-1; i >= 0; --i) {
nodeMultiSet.nodes.splice(attrIndices[i], attrIndices[i], attrNodes[i]);
nodeMultiSet.pos.splice(attrIndices[i], attrIndices[i], [1]);
nodeMultiSet.lasts.splice(attrIndices[i], attrIndices[i], [1]);
}
return nodeMultiSet;
}
/**
*/
function ancestorHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, andSelf) {
var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase);
var ancestors = []; // array of non-empty arrays of matching ancestors
for (var i = 0; i < nodeList.length; ++i) {
var node = nodeList[i];
var isFirst = true;
var a = [];
while (null != node) {
if (!isFirst || andSelf) {
if (matcher.matches(node))
a.push(node);
}
isFirst = false;
node = node.parentNode || node.ownerElement;
}
if (0 < a.length)
ancestors.push(a);
}
var lasts = [];
for (var i = 0; i < ancestors.length; ++i) lasts.push(ancestors[i].length);
var nodeMultiSet = new NodeMultiSet(true);
var newCtx = {nodes:[], pos:[], lasts:[]};
while (0 < ancestors.length) {
var pos = [ancestors[0].length];
var last = [lasts[0]];
var node = ancestors[0].pop();
for (var i = ancestors.length - 1; i > 0; --i) {
if (node === ancestors[i][ancestors[i].length - 1]) {
pos.push(ancestors[i].length);
last.push(lasts[i]);
ancestors[i].pop();
if (0 === ancestors[i].length) {
ancestors.splice(i, i+1);
lasts.splice(i, i+1);
}
}
}
if (0 === ancestors[0].length) {
ancestors.shift();
lasts.shift();
}
newCtx.nodes.push(node);
newCtx.pos.push(pos);
newCtx.lasts.push(last);
}
return newCtx;
}
/** Helper function for sortDocumentOrder. Returns a list of indices, from the
* node to the root, of positions within parent.
* For convenience, the node is the first element of the array.
*/
function addressVector(node) {
var r = [node];
if (null != node.ownerElement) {
node = node.ownerElement;
r.push(-1);
}
while (null != node) {
var i = 0;
while (null != node.previousSibling) {
node = node.previousSibling;
i++;
}
r.push(i);
node = node.parentNode
}
return r;
}
function addressComparator(a, b) {
var minlen = Math.min(a.length - 1, b.length - 1), // not including [0]=node
alen = a.length,
blen = b.length;
if (a[0] === b[0]) return 0;
var c;
for (var i = 0; i < minlen; ++i) {
c = a[alen - i - 1] - b[blen - i - 1];
if (0 !== c)
break;
}
if (null == c || 0 === c) {
// All equal until one of the nodes. The longer one is the descendant.
c = alen - blen;
}
if (0 === c)
c = getNodeName(a) - getNodeName(b);
if (0 === c)
c = 1;
return c;
}
var sortUniqDocumentOrder = xpath.sortUniqDocumentOrder = function(nodes) {
var a = [];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
var v = addressVector(node);
a.push(v);
}
a.sort(addressComparator);
var b = [];
for (var i = 0; i < a.length; i++) {
if (0 < i && a[i][0] === a[i - 1][0])
continue;
b.push(a[i][0]);
}
return b;
}
/** Sort node multiset. Does not do any de-duping. */
function sortNodeMultiSet(nodeMultiSet) {
var a = [];
for (var i = 0; i < nodeMultiSet.nodes.length; i++) {
var v = addressVector(nodeMultiSet.nodes[i]);
a.push({v:v, n:nodeMultiSet.nodes[i],
p:nodeMultiSet.pos[i], l:nodeMultiSet.lasts[i]});
}
a.sort(compare);
var r = {nodes:[], pos:[], lasts:[]};
for (var i = 0; i < a.length; ++i) {
r.nodes.push(a[i].n);
r.pos.push(a[i].p);
r.lasts.push(a[i].l);
}
function compare(x, y) {
return addressComparator(x.v, y.v);
}
return r;
}
/** Returns an array containing all the ancestors down to a node.
* The array starts with document.
*/
function nodeAndAncestors(node) {
var ancestors = [node];
var p = node;
while (p = p.parentNode || p.ownerElement) {
ancestors.unshift(p);
}
return ancestors;
}
function compareSiblings(a, b) {
if (a === b) return 0;
var c = a;
while (c = c.previousSibling) {
if (c === b)
return 1; // b < a
}
c = b;
while (c = c.previousSibling) {
if (c === a)
return -1; // a < b
}
throw new Error('a and b are not siblings: ' + xpath.stringifyObject(a) + ' vs ' + xpath.stringifyObject(b));
}
/** The merge in merge-sort.*/
function mergeNodeLists(x, y) {
var a, b, aanc, banc, r = [];
if ('object' !== typeof x)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Invalid LHS for | operator ' +
'(expected node-set): ' + x);
if ('object' !== typeof y)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Invalid LHS for | operator ' +
'(expected node-set): ' + y);
while (true) {
if (null == a) {
a = x.shift();
if (null != a)
aanc = addressVector(a);
}
if (null == b) {
b = y.shift();
if (null != b)
banc = addressVector(b);
}
if (null == a || null == b) break;
var c = addressComparator(aanc, banc);
if (c < 0) {
r.push(a);
a = null;
aanc = null;
} else if (c > 0) {
r.push(b);
b = null;
banc = null;
} else if (getNodeName(a) < getNodeName(b)) { // attributes
r.push(a);
a = null;
aanc = null;
} else if (getNodeName(a) > getNodeName(b)) { // attributes
r.push(b);
b = null;
banc = null;
} else if (a !== b) {
// choose b arbitrarily
r.push(b);
b = null;
banc = null;
} else {
console.assert(a === b, c);
// just skip b without pushing it.
b = null;
banc = null;
}
}
while (a) {
r.push(a);
a = x.shift();
}
while (b) {
r.push(b);
b = y.shift();
}
return r;
}
function comparisonHelper(test, x, y, isNumericComparison) {
var coersion;
if (isNumericComparison)
coersion = fn.number;
else coersion =
'boolean' === typeof x || 'boolean' === typeof y ? fn['boolean'] :
'number' === typeof x || 'number' === typeof y ? fn.number :
fn.string;
if ('object' === typeof x && 'object' === typeof y) {
var aMap = {};
for (var i = 0; i < x.nodes.length; ++i) {
var xi = coersion({nodes:[x.nodes[i]]});
for (var j = 0; j < y.nodes.length; ++j) {
var yj = coersion({nodes:[y.nodes[j]]});
if (test(xi, yj)) return true;
}
}
return false;
} else if ('object' === typeof x && x.nodes && x.nodes.length) {
for (var i = 0; i < x.nodes.length; ++i) {
var xi = coersion({nodes:[x.nodes[i]]}), yc = coersion(y);
if (test(xi, yc))
return true;
}
return false;
} else if ('object' === typeof y && x.nodes && x.nodes.length) {
for (var i = 0; i < x.nodes.length; ++i) {
var yi = coersion({nodes:[y.nodes[i]]}), xc = coersion(x);
if (test(xc, yi))
return true;
}
return false;
} else {
var xc = coersion(x), yc = coersion(y);
return test(xc, yc);
}
}
var axes = xpath.axes = {
'ancestor':
function ancestor(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
return ancestorHelper(
nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, false);
},
'ancestor-or-self':
function ancestorOrSelf(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
return ancestorHelper(
nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, true);
},
'attribute':
function attribute(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
// TODO: figure out whether positions should be undefined here.
var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase);
var nodeMultiSet = new NodeMultiSet(false);
if (null != nodeName) {
// TODO: with namespace
for (var i = 0; i < nodeList.length; ++i) {
var node = nodeList[i];
if (null == node.getAttributeNode)
continue; // only Element has .getAttributeNode
var attr = node.getAttributeNode(nodeName);
if (null != attr && matcher.matches(attr)) {
nodeMultiSet.pushSeries();
nodeMultiSet.addNode(attr);
nodeMultiSet.popSeries();
}
}
} else {
for (var i = 0; i < nodeList.length; ++i) {
var node = nodeList[i];
if (null != node.attributes) {
nodeMultiSet.pushSeries();
for (var j = 0; j < node.attributes.length; j++) { // all nodes have .attributes
var attr = node.attributes[j];
if (matcher.matches(attr)) // TODO: I think this check is unnecessary
nodeMultiSet.addNode(attr);
}
nodeMultiSet.popSeries();
}
}
}
return nodeMultiSet.finalize();
},
'child':
function child(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase);
var nodeMultiSet = new NodeMultiSet(false);
for (var i = 0; i < nodeList.length; ++i) {
var n = nodeList[i];
if (n.ownerElement) // skip attribute nodes' text child.
continue;
if (n.childNodes) {
nodeMultiSet.pushSeries();
var childList = 1 === nodeTypeNum && null != n.children ?
n.children : n.childNodes;
for (var j = 0; j < childList.length; ++j) {
var child = childList[j];
if (matcher.matches(child)) {
nodeMultiSet.addNode(child);
}
// don't have to do de-duping because children have parent,
// which are current context.
}
nodeMultiSet.popSeries();
}
}
nodeMultiSet.finalize();
return sortNodeMultiSet(nodeMultiSet);
},
'descendant':
function descenant(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
return descenantHelper(
nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, false);
},
'descendant-or-self':
function descenantOrSelf(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
return descenantHelper(
nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, true);
},
'following':
function following(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
return followingHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase);
},
'following-sibling':
function followingSibling(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
return followingSiblingHelper(
nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase,
Array.prototype.shift, function() {return this[0];},
function(node) {return node.nextSibling;});
},
'namespace':
function namespace(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
// TODO
},
'parent':
function parent(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase);
var nodes = [], pos = [];
for (var i = 0; i < nodeList.length; ++i) {
var parent = nodeList[i].parentNode || nodeList[i].ownerElement;
if (null == parent)
continue;
if (!matcher.matches(parent))
continue;
if (nodes.length > 0 && parent === nodes[nodes.length-1])
continue;
nodes.push(parent);
pos.push([1]);
}
return {nodes:nodes, pos:pos, lasts:pos};
},
'preceding':
function preceding(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
return precedingHelper(
nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase);
},
'preceding-sibling':
function precedingSibling(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
return followingSiblingHelper(
nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase,
Array.prototype.pop, function() {return this[this.length-1];},
function(node) {return node.previousSibling},
false, true);
},
'self':
function self(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) {
var nodes = [], pos = [];
var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase);
for (var i = 0; i < nodeList.length; ++i) {
if (matcher.matches(nodeList[i])) {
nodes.push(nodeList[i]);
pos.push([1]);
}
}
return {nodes: nodes, pos: pos, lasts: pos}
}
};
/***************************************************************************
* Evaluation: functions *
***************************************************************************/
var fn = {
'number': function number(optObject) {
if ('number' === typeof optObject)
return optObject;
if ('string' === typeof optObject)
return parseFloat(optObject); // note: parseFloat(' ') -> NaN, unlike +' ' -> 0.
if ('boolean' === typeof optObject)
return +optObject;
return fn.number(fn.string.call(this, optObject)); // for node-sets
},
'string': function string(optObject) {
if (null == optObject)
return fn.string(this);
if ('string' === typeof optObject || 'boolean' === typeof optObject ||
'number' === typeof optObject)
return '' + optObject;
if (0 == optObject.nodes.length) return '';
if (null != optObject.nodes[0].textContent)
return optObject.nodes[0].textContent;
return optObject.nodes[0].nodeValue;
},
'boolean': function booleanVal(x) {
return 'object' === typeof x ? x.nodes.length > 0 : !!x;
},
'last': function last() {
console.assert(Array.isArray(this.pos));
console.assert(Array.isArray(this.lasts));
console.assert(1 === this.pos.length);
console.assert(1 === this.lasts.length);
console.assert(1 === this.lasts[0].length);
return this.lasts[0][0];
},
'position': function position() {
console.assert(Array.isArray(this.pos));
console.assert(Array.isArray(this.lasts));
console.assert(1 === this.pos.length);
console.assert(1 === this.lasts.length);
console.assert(1 === this.pos[0].length);
return this.pos[0][0];
},
'count': function count(nodeSet) {
if ('object' !== typeof nodeSet)
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Position ' + stream.position() +
': Function count(node-set) ' +
'got wrong argument type: ' + nodeSet);
return nodeSet.nodes.length;
},
'id': function id(object) {
var r = {nodes: []};
var doc = this.nodes[0].ownerDocument || this.nodes[0];
console.assert(doc);
var ids;
if ('object' === typeof object) {
// for node-sets, map id over each node value.
ids = [];
for (var i = 0; i < object.nodes.length; ++i) {
var idNode = object.nodes[i];
var idsString = fn.string({nodes:[idNode]});
var a = idsString.split(/[ \t\r\n]+/g);
Array.prototype.push.apply(ids, a);
}
} else {
var idsString = fn.string(object);
var a = idsString.split(/[ \t\r\n]+/g);
ids = a;
}
for (var i = 0; i < ids.length; ++i) {
var id = ids[i];
if (0 === id.length)
continue;
var node = doc.getElementById(id);
if (null != node)
r.nodes.push(node);
}
r.nodes = sortUniqDocumentOrder(r.nodes);
return r;
},
'local-name': function(nodeSet) {
if (null == nodeSet)
return fn.name(this);
if (null == nodeSet.nodes) {
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'argument to name() must be a node-set. got ' + nodeSet);
}
// TODO: namespaced version
return nodeSet.nodes[0].localName;
},
'namespace-uri': function(nodeSet) {
// TODO
throw new Error('not implemented yet');
},
'name': function(nodeSet) {
if (null == nodeSet)
return fn.name(this);
if (null == nodeSet.nodes) {
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'argument to name() must be a node-set. got ' + nodeSet);
}
return nodeSet.nodes[0].name;
},
'concat': function concat(x) {
var l = [];
for (var i = 0; i < arguments.length; ++i) {
l.push(fn.string(arguments[i]));
}
return l.join('');
},
'starts-with': function startsWith(a, b) {
var as = fn.string(a), bs = fn.string(b);
return as.substr(0, bs.length) === bs;
},
'contains': function contains(a, b) {
var as = fn.string(a), bs = fn.string(b);
var i = as.indexOf(bs);
if (-1 === i) return false;
return true;
},
'substring-before': function substringBefore(a, b) {
var as = fn.string(a), bs = fn.string(b);
var i = as.indexOf(bs);
if (-1 === i) return '';
return as.substr(0, i);
},
'substring-after': function substringBefore(a, b) {
var as = fn.string(a), bs = fn.string(b);
var i = as.indexOf(bs);
if (-1 === i) return '';
return as.substr(i + bs.length);
},
'substring': function substring(string, start, optEnd) {
if (null == string || null == start) {
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Must be at least 2 arguments to string()');
}
var sString = fn.string(string),
iStart = fn.round(start),
iEnd = optEnd == null ? null : fn.round(optEnd);
// Note that xpath string positions user 1-based index
if (iEnd == null)
return sString.substr(iStart - 1);
else
return sString.substr(iStart - 1, iEnd);
},
'string-length': function stringLength(optString) {
return fn.string.call(this, optString).length;
},
'normalize-space': function normalizeSpace(optString) {
var s = fn.string.call(this, optString);
return s.replace(/[ \t\r\n]+/g, ' ').replace(/^ | $/g, '');
},
'translate': function translate(string, from, to) {
var sString = fn.string.call(this, string),
sFrom = fn.string(from),
sTo = fn.string(to);
var eachCharRe = [];
var map = {};
for (var i = 0; i < sFrom.length; ++i) {
var c = sFrom.charAt(i);
map[c] = sTo.charAt(i); // returns '' if beyond length of sTo.
// copied from goog.string.regExpEscape in the Closure library.
eachCharRe.push(
c.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, '\\$1').
replace(/\x08/g, '\\x08'));
}
var re = new RegExp(eachCharRe.join('|'), 'g');
return sString.replace(re, function(c) {return map[c];});
},
/// Boolean functions
'not': function not(x) {
var bx = fn['boolean'](x);
return !bx;
},
'true': function trueVal() { return true; },
'false': function falseVal() { return false; },
// TODO
'lang': function lang(string) { throw new Error('Not implemented');},
'sum': function sum(optNodeSet) {
if (null == optNodeSet) return fn.sum(this);
// for node-sets, map id over each node value.
var sum = 0;
for (var i = 0; i < optNodeSet.nodes.length; ++i) {
var node = optNodeSet.nodes[i];
var x = fn.number({nodes:[node]});
sum += x;
}
return sum;
},
'floor': function floor(number) {
return Math.floor(fn.number(number));
},
'ceiling': function ceiling(number) {
return Math.ceil(fn.number(number));
},
'round': function round(number) {
return Math.round(fn.number(number));
}
};
/***************************************************************************
* Evaluation: operators *
***************************************************************************/
var more = {
UnaryMinus: function(x) { return -fn.number(x); },
'+': function(x, y) { return fn.number(x) + fn.number(y); },
'-': function(x, y) { return fn.number(x) - fn.number(y); },
'*': function(x, y) { return fn.number(x) * fn.number(y); },
'div': function(x, y) { return fn.number(x) / fn.number(y); },
'mod': function(x, y) { return fn.number(x) % fn.number(y); },
'<': function(x, y) {
return comparisonHelper(function(x, y) { return fn.number(x) < fn.number(y);}, x, y, true);
},
'<=': function(x, y) {
return comparisonHelper(function(x, y) { return fn.number(x) <= fn.number(y);}, x, y, true);
},
'>': function(x, y) {
return comparisonHelper(function(x, y) { return fn.number(x) > fn.number(y);}, x, y, true);
},
'>=': function(x, y) {
return comparisonHelper(function(x, y) { return fn.number(x) >= fn.number(y);}, x, y, true);
},
'and': function(x, y) { return fn['boolean'](x) && fn['boolean'](y); },
'or': function(x, y) { return fn['boolean'](x) || fn['boolean'](y); },
'|': function(x, y) { return {nodes: mergeNodeLists(x.nodes, y.nodes)}; },
'=': function(x, y) {
// optimization for two node-sets case: avoid n^2 comparisons.
if ('object' === typeof x && 'object' === typeof y) {
var aMap = {};
for (var i = 0; i < x.nodes.length; ++i) {
var s = fn.string({nodes:[x.nodes[i]]});
aMap[s] = true;
}
for (var i = 0; i < y.nodes.length; ++i) {
var s = fn.string({nodes:[y.nodes[i]]});
if (aMap[s]) return true;
}
return false;
} else {
return comparisonHelper(function(x, y) {return x === y;}, x, y);
}
},
'!=': function(x, y) {
// optimization for two node-sets case: avoid n^2 comparisons.
if ('object' === typeof x && 'object' === typeof y) {
if (0 === x.nodes.length || 0 === y.nodes.length) return false;
var aMap = {};
for (var i = 0; i < x.nodes.length; ++i) {
var s = fn.string({nodes:[x.nodes[i]]});
aMap[s] = true;
}
for (var i = 0; i < y.nodes.length; ++i) {
var s = fn.string({nodes:[y.nodes[i]]});
if (!aMap[s]) return true;
}
return false;
} else {
return comparisonHelper(function(x, y) {return x !== y;}, x, y);
}
}
};
var nodeTypes = xpath.nodeTypes = {
'node': 0,
'attribute': 2,
'comment': 8, // this.doc.COMMENT_NODE,
'text': 3, // this.doc.TEXT_NODE,
'processing-instruction': 7, // this.doc.PROCESSING_INSTRUCTION_NODE,
'element': 1 //this.doc.ELEMENT_NODE
};
/** For debugging and unit tests: returnjs a stringified version of the
* argument. */
var stringifyObject = xpath.stringifyObject = function stringifyObject(ctx) {
var seenKey = 'seen' + Math.floor(Math.random()*1000000000);
return JSON.stringify(helper(ctx));
function helper(ctx) {
if (Array.isArray(ctx)) {
return ctx.map(function(x) {return helper(x);});
}
if ('object' !== typeof ctx) return ctx;
if (null == ctx) return ctx;
// if (ctx.toString) return ctx.toString();
if (null != ctx.outerHTML) return ctx.outerHTML;
if (null != ctx.nodeValue) return ctx.nodeName + '=' + ctx.nodeValue;
if (ctx[seenKey]) return '[circular]';
ctx[seenKey] = true;
var nicer = {};
for (var key in ctx) {
if (seenKey === key)
continue;
try {
nicer[key] = helper(ctx[key]);
} catch (e) {
nicer[key] = '[exception: ' + e.message + ']';
}
}
delete ctx[seenKey];
return nicer;
}
}
var Evaluator = xpath.Evaluator = function Evaluator(doc) {
this.doc = doc;
}
Evaluator.prototype = {
val: function val(ast, ctx) {
console.assert(ctx.nodes);
if ('number' === typeof ast || 'string' === typeof ast) return ast;
if (more[ast[0]]) {
var evaluatedParams = [];
for (var i = 1; i < ast.length; ++i) {
evaluatedParams.push(this.val(ast[i], ctx));
}
var r = more[ast[0]].apply(ctx, evaluatedParams);
return r;
}
switch (ast[0]) {
case 'Root': return {nodes: [this.doc]};
case 'FunctionCall':
var functionName = ast[1], functionParams = ast[2];
if (null == fn[functionName])
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
'Unknown function: ' + functionName);
var evaluatedParams = [];
for (var i = 0; i < functionParams.length; ++i) {
evaluatedParams.push(this.val(functionParams[i], ctx));
}
var r = fn[functionName].apply(ctx, evaluatedParams);
return r;
case 'Predicate':
var lhs = this.val(ast[1], ctx);
var ret = {nodes: []};
var contexts = eachContext(lhs);
for (var i = 0; i < contexts.length; ++i) {
var singleNodeSet = contexts[i];
var rhs = this.val(ast[2], singleNodeSet);
var success;
if ('number' === typeof rhs) {
success = rhs === singleNodeSet.pos[0][0];
} else {
success = fn['boolean'](rhs);
}
if (success) {
var node = singleNodeSet.nodes[0];
ret.nodes.push(node);
// skip over all the rest of the same node.
while (i+1 < contexts.length && node === contexts[i+1].nodes[0]) {
i++;
}
}
}
return ret;
case 'PathExpr':
// turn the path into an expressoin; i.e., remove the position
// information of the last axis.
var x = this.val(ast[1], ctx);
// Make the nodeset a forward-direction-only one.
if (x.finalize) { // it is a NodeMultiSet
return {nodes: x.nodes};
} else {
return x;
}
case '/':
// TODO: don't generate '/' nodes, just Axis nodes.
var lhs = this.val(ast[1], ctx);
console.assert(null != lhs);
var r = this.val(ast[2], lhs);
console.assert(null != r);
return r;
case 'Axis':
// All the axis tests from Step. We only get AxisSpecifier NodeTest,
// not the predicate (which is applied later)
var axis = ast[1],
nodeType = ast[2],
nodeTypeNum = nodeTypes[nodeType],
shouldLowerCase = true, // TODO: give option
nodeName = ast[3] && shouldLowerCase ? ast[3].toLowerCase() : ast[3];
nodeName = nodeName === '*' ? null : nodeName;
if ('object' !== typeof ctx) return {nodes:[], pos:[]};
var nodeList = ctx.nodes.slice(); // TODO: is copy needed?
var r = axes[axis](nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase);
return r;
}
}
};
var evaluate = xpath.evaluate = function evaluate(expr, doc, context) {
//var astFactory = new AstEvaluatorFactory(doc, context);
var stream = new Stream(expr);
var ast = parse(stream, astFactory);
var val = new Evaluator(doc).val(ast, {nodes: [context]});
return val;
}
/***************************************************************************
* DOM interface *
***************************************************************************/
var XPathException = xpath.XPathException = function XPathException(code, message) {
var e = new Error(message);
e.name = 'XPathException';
e.code = code;
return e;
}
XPathException.INVALID_EXPRESSION_ERR = 51;
XPathException.TYPE_ERR = 52;
var XPathEvaluator = xpath.XPathEvaluator = function XPathEvaluator() {}
XPathEvaluator.prototype = {
createExpression: function(expression, resolver) {
return new XPathExpression(expression, resolver);
},
createNSResolver: function(nodeResolver) {
// TODO
},
evaluate: function evaluate(expression, contextNode, resolver, type, result) {
var expr = new XPathExpression(expression, resolver);
return expr.evaluate(contextNode, type, result);
}
};
var XPathExpression = xpath.XPathExpression = function XPathExpression(expression, resolver, optDoc) {
var stream = new Stream(expression);
this._ast = parse(stream, astFactory);
this._doc = optDoc;
}
XPathExpression.prototype = {
evaluate: function evaluate(contextNode, type, result) {
if (null == contextNode.nodeType)
throw new Error('bad argument (expected context node): ' + contextNode);
var doc = contextNode.ownerDocument || contextNode;
if (null != this._doc && this._doc !== doc) {
throw new core.DOMException(
core.DOMException.WRONG_DOCUMENT_ERR,
'The document must be the same as the context node\'s document.');
}
var evaluator = new Evaluator(doc);
var value = evaluator.val(this._ast, {nodes: [contextNode]});
if (XPathResult.NUMBER_TYPE === type)
value = fn.number(value);
else if (XPathResult.STRING_TYPE === type)
value = fn.string(value);
else if (XPathResult.BOOLEAN_TYPE === type)
value = fn['boolean'](value);
else if (XPathResult.ANY_TYPE !== type &&
XPathResult.UNORDERED_NODE_ITERATOR_TYPE !== type &&
XPathResult.ORDERED_NODE_ITERATOR_TYPE !== type &&
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE !== type &&
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE !== type &&
XPathResult.ANY_UNORDERED_NODE_TYPE !== type &&
XPathResult.FIRST_ORDERED_NODE_TYPE !== type)
throw new core.DOMException(
core.DOMException.NOT_SUPPORTED_ERR,
'You must provide an XPath result type (0=any).');
else if (XPathResult.ANY_TYPE !== type &&
'object' !== typeof value)
throw new XPathException(
XPathException.TYPE_ERR,
'Value should be a node-set: ' + value);
return new XPathResult(doc, value, type);
}
}
var XPathResult = xpath.XPathResult = function XPathResult(doc, value, resultType) {
this._value = value;
this._resultType = resultType;
this._i = 0;
// TODO: we removed mutation events but didn't take care of this. No tests fail, so that's nice, but eventually we
// should fix this, preferably by entirely replacing our XPath implementation.
// this._invalidated = false;
// if (this.resultType === XPathResult.UNORDERED_NODE_ITERATOR_TYPE ||
// this.resultType === XPathResult.ORDERED_NODE_ITERATOR_TYPE) {
// doc.addEventListener('DOMSubtreeModified', invalidate, true);
// var self = this;
// function invalidate() {
// self._invalidated = true;
// doc.removeEventListener('DOMSubtreeModified', invalidate, true);
// }
// }
}
XPathResult.ANY_TYPE = 0;
XPathResult.NUMBER_TYPE = 1;
XPathResult.STRING_TYPE = 2;
XPathResult.BOOLEAN_TYPE = 3;
XPathResult.UNORDERED_NODE_ITERATOR_TYPE = 4;
XPathResult.ORDERED_NODE_ITERATOR_TYPE = 5;
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE = 6;
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE = 7;
XPathResult.ANY_UNORDERED_NODE_TYPE = 8;
XPathResult.FIRST_ORDERED_NODE_TYPE = 9;
var proto = {
// XPathResultType
get resultType() {
if (this._resultType) return this._resultType;
switch (typeof this._value) {
case 'number': return XPathResult.NUMBER_TYPE;
case 'string': return XPathResult.STRING_TYPE;
case 'boolean': return XPathResult.BOOLEAN_TYPE;
default: return XPathResult.UNORDERED_NODE_ITERATOR_TYPE;
}
},
get numberValue() {
if (XPathResult.NUMBER_TYPE !== this.resultType)
throw new XPathException(XPathException.TYPE_ERR,
'You should have asked for a NUMBER_TYPE.');
return this._value;
},
get stringValue() {
if (XPathResult.STRING_TYPE !== this.resultType)
throw new XPathException(XPathException.TYPE_ERR,
'You should have asked for a STRING_TYPE.');
return this._value;
},
get booleanValue() {
if (XPathResult.BOOLEAN_TYPE !== this.resultType)
throw new XPathException(XPathException.TYPE_ERR,
'You should have asked for a BOOLEAN_TYPE.');
return this._value;
},
get singleNodeValue() {
if (XPathResult.ANY_UNORDERED_NODE_TYPE !== this.resultType &&
XPathResult.FIRST_ORDERED_NODE_TYPE !== this.resultType)
throw new XPathException(
XPathException.TYPE_ERR,
'You should have asked for a FIRST_ORDERED_NODE_TYPE.');
return this._value.nodes[0] || null;
},
get invalidIteratorState() {
if (XPathResult.UNORDERED_NODE_ITERATOR_TYPE !== this.resultType &&
XPathResult.ORDERED_NODE_ITERATOR_TYPE !== this.resultType)
return false;
return !!this._invalidated;
},
get snapshotLength() {
if (XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE !== this.resultType &&
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE !== this.resultType)
throw new XPathException(
XPathException.TYPE_ERR,
'You should have asked for a ORDERED_NODE_SNAPSHOT_TYPE.');
return this._value.nodes.length;
},
iterateNext: function iterateNext() {
if (XPathResult.UNORDERED_NODE_ITERATOR_TYPE !== this.resultType &&
XPathResult.ORDERED_NODE_ITERATOR_TYPE !== this.resultType)
throw new XPathException(
XPathException.TYPE_ERR,
'You should have asked for a ORDERED_NODE_ITERATOR_TYPE.');
if (this.invalidIteratorState)
throw new core.DOMException(
core.DOMException.INVALID_STATE_ERR,
'The document has been mutated since the result was returned');
return this._value.nodes[this._i++] || null;
},
snapshotItem: function snapshotItem(index) {
if (XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE !== this.resultType &&
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE !== this.resultType)
throw new XPathException(
XPathException.TYPE_ERR,
'You should have asked for a ORDERED_NODE_SNAPSHOT_TYPE.');
return this._value.nodes[index] || null;
}
};
// so you can access ANY_TYPE etc. from the instances:
XPathResult.prototype = Object.create(XPathResult,
Object.keys(proto).reduce(function (descriptors, name) {
descriptors[name] = Object.getOwnPropertyDescriptor(proto, name);
return descriptors;
}, {
constructor: {
value: XPathResult,
writable: true,
configurable: true
}
}));
core.XPathException = XPathException;
core.XPathExpression = XPathExpression;
core.XPathResult = XPathResult;
core.XPathEvaluator = XPathEvaluator;
core.Document.prototype.createExpression =
XPathEvaluator.prototype.createExpression;
core.Document.prototype.createNSResolver =
XPathEvaluator.prototype.createNSResolver;
core.Document.prototype.evaluate = XPathEvaluator.prototype.evaluate;
return xpath; // for tests
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| attributes.js | 20.36% | (45 / 221) | 0% | (0 / 97) | 0% | (0 / 31) | 20.45% | (45 / 220) | |
| dom-token-list.js | 12.26% | (13 / 106) | 0% | (0 / 38) | 0% | (0 / 20) | 12.26% | (13 / 106) | |
| html-collection.js | 22.41% | (13 / 58) | 0% | (0 / 24) | 11.11% | (1 / 9) | 22.41% | (13 / 58) | |
| index.js | 100% | (46 / 46) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (46 / 46) | |
| named-properties-window.js | 19.12% | (13 / 68) | 0% | (0 / 60) | 0% | (0 / 7) | 19.12% | (13 / 68) | |
| node-document-position.js | 100% | (1 / 1) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (1 / 1) | |
| node-filter.js | 71.43% | (5 / 7) | 100% | (0 / 0) | 33.33% | (1 / 3) | 71.43% | (5 / 7) | |
| node-iterator.js | 19.83% | (23 / 116) | 0% | (0 / 51) | 5.88% | (1 / 17) | 19.83% | (23 / 116) | |
| node-list.js | 20.75% | (11 / 53) | 0% | (0 / 12) | 9.09% | (1 / 11) | 20.75% | (11 / 53) | |
| node-type.js | 100% | (1 / 1) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (1 / 1) | |
| node.js | 11% | (11 / 100) | 0% | (0 / 66) | 0% | (0 / 9) | 11.11% | (11 / 99) | |
| post-message.js | 21.43% | (3 / 14) | 0% | (0 / 8) | 0% | (0 / 1) | 21.43% | (3 / 14) | |
| register-elements.js | 90% | (9 / 10) | 0% | (0 / 2) | 100% | (0 / 0) | 90% | (9 / 10) | |
| xhr-utils.js | 8.33% | (16 / 192) | 0% | (0 / 72) | 0% | (0 / 8) | 8.74% | (16 / 183) | |
| xmlhttprequest-event-target.js | 33.33% | (5 / 15) | 0% | (0 / 2) | 50% | (1 / 2) | 33.33% | (5 / 15) | |
| xmlhttprequest-symbols.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| xmlhttprequest-upload.js | 50% | (3 / 6) | 0% | (0 / 2) | 50% | (1 / 2) | 50% | (3 / 6) | |
| xmlhttprequest.js | 6.41% | (38 / 593) | 0.27% | (1 / 372) | 0% | (0 / 34) | 6.44% | (38 / 590) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 21 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const DOMException = require("../web-idl/DOMException");
const defineGetter = require("../utils").defineGetter;
const idlUtils = require("./generated/utils");
const attrGenerated = require("./generated/Attr");
const changeAttributeImpl = require("./attributes/Attr-impl").changeAttributeImpl;
const getAttrImplQualifiedName = require("./attributes/Attr-impl").getAttrImplQualifiedName;
// https://dom.spec.whatwg.org/#namednodemap
const INTERNAL = Symbol("NamedNodeMap internal");
// TODO: use NamedPropertyTracker when https://github.com/tmpvar/jsdom/pull/1116 lands?
// Don't emulate named getters for these properties.
// Compiled later after NamedNodeMap is all set up.
const reservedNames = new Set();
function NamedNodeMap() {
throw new TypeError("Illegal constructor");
}
defineGetter(NamedNodeMap.prototype, "length", function () {
return this[INTERNAL].attributeList.length;
});
NamedNodeMap.prototype.item = function (index) {
if (arguments.length < 1) {
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.item");
}
// Don't bother with full unsigned long long conversion. When we have better WebIDL support generally, revisit.
index = Number(index);
return this[index] || null;
};
NamedNodeMap.prototype.getNamedItem = function (name) {
if (arguments.length < 1) {
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.getNamedItem");
}
name = String(name);
return idlUtils.wrapperForImpl(exports.getAttributeByName(this[INTERNAL].element, name));
};
NamedNodeMap.prototype.getNamedItemNS = function (namespace, localName) {
if (arguments.length < 2) {
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.getNamedItemNS");
}
if (namespace === undefined || namespace === null) {
namespace = null;
} else {
namespace = String(namespace);
}
localName = String(localName);
return idlUtils.wrapperForImpl(exports.getAttributeByNameNS(this[INTERNAL].element, namespace, localName));
};
NamedNodeMap.prototype.setNamedItem = function (attr) {
if (!attrGenerated.is(attr)) {
throw new TypeError("First argument to NamedNodeMap.prototype.setNamedItem must be an Attr");
}
return idlUtils.wrapperForImpl(exports.setAttribute(this[INTERNAL].element, idlUtils.implForWrapper(attr)));
};
NamedNodeMap.prototype.setNamedItemNS = function (attr) {
if (!attrGenerated.is(attr)) {
throw new TypeError("First argument to NamedNodeMap.prototype.setNamedItemNS must be an Attr");
}
return idlUtils.wrapperForImpl(exports.setAttribute(this[INTERNAL].element, idlUtils.implForWrapper(attr)));
};
NamedNodeMap.prototype.removeNamedItem = function (name) {
if (arguments.length < 1) {
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.getNamedItem");
}
name = String(name);
const attr = exports.removeAttributeByName(this[INTERNAL].element, name);
if (attr === null) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "Tried to remove an attribute that was not present");
}
return idlUtils.wrapperForImpl(attr);
};
NamedNodeMap.prototype.removeNamedItemNS = function (namespace, localName) {
if (arguments.length < 2) {
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.removeNamedItemNS");
}
if (namespace === undefined || namespace === null) {
namespace = null;
} else {
namespace = String(namespace);
}
localName = String(localName);
const attr = exports.removeAttributeByNameNS(this[INTERNAL].element, namespace, localName);
if (attr === null) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "Tried to remove an attribute that was not present");
}
return idlUtils.wrapperForImpl(attr);
};
exports.NamedNodeMap = NamedNodeMap;
{
let prototype = NamedNodeMap.prototype;
while (prototype) {
for (const name of Object.getOwnPropertyNames(prototype)) {
reservedNames.add(name);
}
prototype = Object.getPrototypeOf(prototype);
}
}
exports.createNamedNodeMap = function (element) {
const nnm = Object.create(NamedNodeMap.prototype);
nnm[INTERNAL] = {
element,
attributeList: [],
attributesByNameMap: new Map()
};
return nnm;
};
// The following three are for https://dom.spec.whatwg.org/#concept-element-attribute-has. We don't just have a
// predicate tester since removing that kind of flexibility gives us the potential for better future optimizations.
exports.hasAttribute = function (element, A) {
const attributesNNM = element._attributes;
const attributeList = attributesNNM[INTERNAL].attributeList;
return attributeList.indexOf(A) !== -1;
};
exports.hasAttributeByName = function (element, name) {
const attributesNNM = element._attributes;
const attributesByNameMap = attributesNNM[INTERNAL].attributesByNameMap;
return attributesByNameMap.has(name);
};
exports.hasAttributeByNameNS = function (element, namespace, localName) {
const attributesNNM = element._attributes;
const attributeList = attributesNNM[INTERNAL].attributeList;
return attributeList.some(attribute => {
return attribute._localName === localName && attribute._namespace === namespace;
});
};
exports.changeAttribute = function (element, attribute, value) {
// https://dom.spec.whatwg.org/#concept-element-attributes-change
// The partitioning here works around a particularly bad circular require problem. See
// https://github.com/tmpvar/jsdom/pull/1247#issuecomment-149060470
changeAttributeImpl(element, attribute, value);
};
exports.appendAttribute = function (element, attribute) {
// https://dom.spec.whatwg.org/#concept-element-attributes-append
const attributesNNM = element._attributes;
const attributeList = attributesNNM[INTERNAL].attributeList;
// TODO mutation observer stuff
attributeList.push(attribute);
attribute._element = element;
// Sync target indexed properties
attributesNNM[attributeList.length - 1] = idlUtils.wrapperForImpl(attribute);
const name = getAttrImplQualifiedName(attribute);
// Sync target named properties
if (!reservedNames.has(name) && shouldNameBeInNNMProps(element, name)) {
Object.defineProperty(attributesNNM, name, {
configurable: true,
writable: true,
enumerable: false,
value: idlUtils.wrapperForImpl(attribute)
});
}
// Sync name cache
const cache = attributesNNM[INTERNAL].attributesByNameMap;
let entry = cache.get(name);
if (!entry) {
entry = [];
cache.set(name, entry);
}
entry.push(attribute);
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is added."
element._attrModified(name, attribute._value, null);
};
exports.removeAttribute = function (element, attribute) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove
const attributesNNM = element._attributes;
const attributeList = attributesNNM[INTERNAL].attributeList;
// TODO mutation observer stuff
for (let i = 0; i < attributeList.length; ++i) {
if (attributeList[i] === attribute) {
attributeList.splice(i, 1);
attribute._element = null;
// Sync target indexed properties
for (let j = i; j < attributeList.length; ++j) {
attributesNNM[j] = idlUtils.wrapperForImpl(attributeList[j]);
}
delete attributesNNM[attributeList.length];
const name = getAttrImplQualifiedName(attribute);
// Sync target named properties
if (!reservedNames.has(name) && shouldNameBeInNNMProps(element, name)) {
delete attributesNNM[name];
}
// Sync name cache
const cache = attributesNNM[INTERNAL].attributesByNameMap;
const entry = cache.get(name);
entry.splice(entry.indexOf(attribute), 1);
if (entry.length === 0) {
cache.delete(name);
}
// Run jsdom hooks; roughly correspond to spec's "An attribute is removed."
element._attrModified(name, null, attribute._value);
return;
}
}
};
exports.replaceAttribute = function (element, oldAttr, newAttr) {
// https://dom.spec.whatwg.org/#concept-element-attributes-replace
const attributesNNM = element._attributes;
const attributeList = attributesNNM[INTERNAL].attributeList;
// TODO mutation observer stuff
for (let i = 0; i < attributeList.length; ++i) {
if (attributeList[i] === oldAttr) {
attributeList.splice(i, 1, newAttr);
oldAttr._element = null;
newAttr._element = element;
// Sync target indexed properties
attributesNNM[i] = idlUtils.wrapperForImpl(newAttr);
const name = getAttrImplQualifiedName(newAttr);
// Sync target named properties
if (!reservedNames.has(name) && shouldNameBeInNNMProps(element, name)) {
attributesNNM[name] = newAttr;
}
// Sync name cache
const cache = attributesNNM[INTERNAL].attributesByNameMap;
let entry = cache.get(name);
if (!entry) {
entry = [];
cache.set(name, entry);
}
entry.splice(entry.indexOf(oldAttr), 1, newAttr);
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed."
element._attrModified(name, newAttr._value, oldAttr._value);
return;
}
}
};
exports.getAttributeByName = function (element, name) {
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
if (element._namespaceURI === "http://www.w3.org/1999/xhtml" &&
element._ownerDocument._parsingMode === "html") {
name = name.toLowerCase();
}
const cache = element._attributes[INTERNAL].attributesByNameMap;
const entry = cache.get(name);
if (!entry) {
return null;
}
return entry[0];
};
exports.getAttributeValue = function (element, name) {
const attr = exports.getAttributeByName(element, name);
if (!attr) {
return null;
}
return attr._value;
};
exports.getAttributeByNameNS = function (element, namespace, localName) {
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
if (namespace === "") {
namespace = null;
}
const attributeList = element._attributes[INTERNAL].attributeList;
for (let i = 0; i < attributeList.length; ++i) {
const attr = attributeList[i];
if (attr._namespace === namespace && attr._localName === localName) {
return attr;
}
}
return null;
};
exports.getAttributeValueByNameNS = function (element, namespace, localName) {
const attr = exports.getAttributeByNameNS(element, namespace, localName);
if (!attr) {
return null;
}
return attr._value;
};
exports.setAttribute = function (element, attr) {
// https://dom.spec.whatwg.org/#concept-element-attributes-set
if (attr._element !== null && attr._element !== element) {
throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);
}
const oldAttr = exports.getAttributeByNameNS(element, attr._namespace, attr._localName);
if (oldAttr === attr) {
return attr;
}
if (oldAttr !== null) {
exports.replaceAttribute(element, oldAttr, attr);
} else {
exports.appendAttribute(element, attr);
}
return oldAttr;
};
exports.setAttributeValue = function (element, localName, value, prefix, namespace) {
// https://dom.spec.whatwg.org/#concept-element-attributes-set-value
if (prefix === undefined) {
prefix = null;
}
if (namespace === undefined) {
namespace = null;
}
const attribute = exports.getAttributeByNameNS(element, namespace, localName);
if (attribute === null) {
const newAttribute = attrGenerated.createImpl([], { namespace, namespacePrefix: prefix, localName, value });
exports.appendAttribute(element, newAttribute);
return;
}
exports.changeAttribute(element, attribute, value);
};
exports.removeAttributeByName = function (element, name) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name
const attr = exports.getAttributeByName(element, name);
if (attr !== null) {
exports.removeAttribute(element, attr);
}
return attr;
};
exports.removeAttributeByNameNS = function (element, namespace, localName) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace
const attr = exports.getAttributeByNameNS(element, namespace, localName);
if (attr !== null) {
exports.removeAttribute(element, attr);
}
return attr;
};
exports.copyAttributeList = function (sourceElement, destElement) {
// Needed by https://dom.spec.whatwg.org/#concept-node-clone
for (const sourceAttr of sourceElement._attributes[INTERNAL].attributeList) {
const destAttr = attrGenerated.createImpl([], {
namespace: sourceAttr._namespace,
namespacePrefix: sourceAttr._namespacePrefix,
localName: sourceAttr._localName,
value: sourceAttr._value
});
exports.appendAttribute(destElement, destAttr);
}
};
exports.attributeListsEqual = function (elementA, elementB) {
// Needed by https://dom.spec.whatwg.org/#concept-node-equals
const listA = elementA._attributes[INTERNAL].attributeList;
const listB = elementB._attributes[INTERNAL].attributeList;
if (listA.length !== listB.length) {
return false;
}
for (let i = 0; i < listA.length; ++i) {
const attrA = listA[i];
if (!listB.some(attrB => equalsA(attrB))) {
return false;
}
function equalsA(attrB) {
return attrA._namespace === attrB._namespace && attrA._localName === attrB._localName &&
attrA._value === attrB._value;
}
}
return true;
};
exports.attributeNames = function (element) {
// Needed by https://dom.spec.whatwg.org/#dom-element-getattributenames
return element._attributes[INTERNAL].attributeList.map(getAttrImplQualifiedName);
};
exports.hasAttributes = function (element) {
// Needed by https://dom.spec.whatwg.org/#dom-element-hasattributes
return element._attributes[INTERNAL].attributeList.length > 0;
};
function shouldNameBeInNNMProps(element, name) {
if (element._ownerDocument._parsingMode === "html" && element._namespaceURI === "http://www.w3.org/1999/xhtml") {
return name.toLowerCase() === name;
}
return true;
}
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const DOMException = require("../web-idl/DOMException");
const orderedSetParser = require("./helpers/ordered-set-parser");
// https://dom.spec.whatwg.org/#domtokenlist
const INTERNAL = Symbol("DOMTokenList internal");
class DOMTokenList {
constructor() {
throw new TypeError("Illegal constructor");
}
item(index) {
const length = this.length;
return length <= index || index < 0 ? null : this[index];
}
contains(token) {
token = String(token);
return indexOf(this, token) !== -1;
}
replace(token, newToken) {
token = String(token);
newToken = String(newToken);
validateTokens(token, newToken);
const tokenIndex = indexOf(this, token);
if (tokenIndex === -1) {
return;
}
const newTokenIndex = indexOf(this, newToken);
if (newTokenIndex !== -1) {
spliceLite(this, newTokenIndex, 1);
}
this[INTERNAL].tokens[tokenIndex] = newToken;
update(this);
}
add(/* tokens... */) {
for (let i = 0; i < arguments.length; i++) {
const token = String(arguments[i]);
validateTokens(token);
if (indexOf(this, token) === -1) {
push(this, token);
}
}
update(this);
}
remove(/* tokens... */) {
for (let i = 0; i < arguments.length; i++) {
const token = String(arguments[i]);
validateTokens(token);
const index = indexOf(this, token);
if (index !== -1) {
spliceLite(this, index, 1);
}
}
update(this);
}
// if force is true, this behaves like add
// if force is false, this behaves like remove
// if force is undefined, this behaves as one would expect toggle to
// always returns whether classList contains token after toggling
toggle(token, force) {
token = String(token);
force = force === undefined ? undefined : Boolean(force);
validateTokens(token);
const index = indexOf(this, token);
if (index !== -1) {
if (force === false || force === undefined) {
spliceLite(this, index, 1);
update(this);
return false;
}
return true;
}
if (force === false) {
return false;
}
push(this, token);
update(this);
return true;
}
get length() {
return this[INTERNAL].tokens.length;
}
get value() {
return serialize(this);
}
set value(v) {
this[INTERNAL].element.setAttribute(this[INTERNAL].attribute, v);
}
toString() {
return serialize(this);
}
}
function serialize(list) {
const value = list[INTERNAL].element.getAttribute(list[INTERNAL].attribute);
return value === null ? "" : value;
}
function validateTokens(/* tokens... */) {
for (let i = 0; i < arguments.length; i++) {
const token = String(arguments[i]);
if (token === "") {
throw new DOMException(DOMException.SYNTAX_ERR, "The token provided must not be empty.");
}
}
for (let i = 0; i < arguments.length; i++) {
const token = String(arguments[i]);
if (/\s/.test(token)) {
const whitespaceMsg = "The token provided contains HTML space characters, which are not valid in tokens.";
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, whitespaceMsg);
}
}
}
function update(list) {
const attribute = list[INTERNAL].attribute;
list[INTERNAL].element.setAttribute(attribute, list[INTERNAL].tokens.join(" "));
}
// calls indexOf on internal array
function indexOf(dtl, token) {
return dtl[INTERNAL].tokens.indexOf(token);
}
// calls push on internal array, then manually adds indexed property to dtl
function push(dtl, token) {
const len = dtl[INTERNAL].tokens.push(token);
dtl[len - 1] = token;
return len;
}
// calls splice on internal array then rewrites indexed properties of dtl
// does not allow items to be added, only removed, so splice-lite
function spliceLite(dtl, start, deleteCount) {
const tokens = dtl[INTERNAL].tokens;
const removedTokens = tokens.splice(start, deleteCount);
// remove indexed properties from list
const re = /^\d+$/;
for (const prop in dtl) {
if (re.test(prop)) {
delete dtl[prop];
}
}
// copy indexed properties from internal array
const len = tokens.length;
for (let i = 0; i < len; i++) {
dtl[i] = tokens[i];
}
return removedTokens;
}
exports.DOMTokenList = DOMTokenList;
// set dom token list without running update steps
exports.reset = function resetDOMTokenList(list, value) {
const tokens = list[INTERNAL].tokens;
spliceLite(list, 0, tokens.length);
if (value) {
for (const token of orderedSetParser(value)) {
push(list, token);
}
}
};
exports.create = function createDOMTokenList(element, attribute) {
const list = Object.create(DOMTokenList.prototype);
list[INTERNAL] = {
element,
attribute,
tokens: []
};
exports.reset(list, element.getAttribute(attribute));
return list;
};
exports.contains = function domTokenListContains(list, token, options) {
const caseInsensitive = options && options.caseInsensitive;
if (!caseInsensitive) {
return indexOf(list, token) !== -1;
}
const tokens = list[INTERNAL].tokens;
const lowerToken = token.toLowerCase();
for (let i = 0; i < tokens.length; ++i) {
if (tokens[i].toLowerCase() === lowerToken) {
return true;
}
}
return false;
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const lengthFromProperties = require("../utils").lengthFromProperties;
const getAttributeValue = require("./attributes").getAttributeValue;
const idlUtils = require("./generated/utils");
const privates = Symbol("HTMLCollection internal slots");
const conflictKeys = new Set(["length", "item", "namedItem"]);
class HTMLCollection {
constructor(secret, element, query) {
if (secret !== privates) {
throw new TypeError("Invalid constructor");
}
this[privates] = { element, query, keys: [], length: 0, version: -1, conflictElements: Object.create(null) };
updateHTMLCollection(this);
}
get length() {
updateHTMLCollection(this);
return this[privates].length;
}
item(index) {
updateHTMLCollection(this);
return this[index] || null;
}
namedItem(name) {
updateHTMLCollection(this);
if (conflictKeys.has(name)) {
return this[privates].conflictElements[name] || null;
}
if (Object.prototype.hasOwnProperty.call(this, name)) {
return this[name];
}
return null;
}
}
HTMLCollection.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
function updateHTMLCollection(collection) {
if (collection[privates].version < collection[privates].element._version) {
resetHTMLCollectionTo(collection, collection[privates].query());
collection[privates].version = collection[privates].element._version;
}
}
function resetHTMLCollectionTo(collection, impls) {
const wrappers = impls.map(idlUtils.wrapperForImpl);
const startingLength = lengthFromProperties(collection);
for (let i = 0; i < startingLength; ++i) {
delete collection[i];
}
for (let i = 0; i < wrappers.length; ++i) {
collection[i] = wrappers[i];
}
collection[privates].length = wrappers.length;
const keys = collection[privates].keys;
for (let i = 0; i < keys.length; ++i) {
delete collection[keys[i]];
}
keys.length = 0;
for (let i = 0; i < impls.length; ++i) {
addIfAttrPresent(impls[i], wrappers[i], "name");
}
for (let i = 0; i < impls.length; ++i) {
addIfAttrPresent(impls[i], wrappers[i], "id");
}
function addIfAttrPresent(impl, wrapper, attr) {
const value = getAttributeValue(impl, attr);
if (value === null || value === "") {
return;
}
// Don't overwrite numeric indices with named ones.
const valueAsNumber = Number(value);
if (!Number.isNaN(valueAsNumber) && valueAsNumber >= 0) {
return;
}
// Don't override existing named ones
if (keys.indexOf(value) !== -1) {
return;
}
if (conflictKeys.has(value)) {
collection[privates].conflictElements[value] = wrapper;
} else {
collection[value] = wrapper;
}
keys.push(value);
}
}
module.exports = function (core) {
core.HTMLCollection = HTMLCollection;
};
module.exports.create = function (element, query) {
return new HTMLCollection(privates, element, query);
};
module.exports.update = updateHTMLCollection;
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
exports.DOMException = require("../web-idl/DOMException");
exports.NamedNodeMap = require("./attributes").NamedNodeMap;
exports.Attr = require("./generated/Attr").interface;
exports.Node = require("./generated/Node").interface;
exports.Element = require("./generated/Element").interface;
exports.DocumentFragment = require("./generated/DocumentFragment").interface;
exports.Document = exports.HTMLDocument = require("./generated/Document").interface;
exports.XMLDocument = require("./generated/XMLDocument").interface;
exports.CharacterData = require("./generated/CharacterData").interface;
exports.Text = require("./generated/Text").interface;
exports.CDATASection = require("./generated/CDATASection").interface;
exports.ProcessingInstruction = require("./generated/ProcessingInstruction").interface;
exports.Comment = require("./generated/Comment").interface;
exports.DocumentType = require("./generated/DocumentType").interface;
exports.DOMImplementation = require("./generated/DOMImplementation").interface;
exports.Event = require("./generated/Event").interface;
exports.CustomEvent = require("./generated/CustomEvent").interface;
exports.MessageEvent = require("./generated/MessageEvent").interface;
exports.ErrorEvent = require("./generated/ErrorEvent").interface;
exports.HashChangeEvent = require("./generated/HashChangeEvent").interface;
exports.FocusEvent = require("./generated/FocusEvent").interface;
exports.PopStateEvent = require("./generated/PopStateEvent").interface;
exports.UIEvent = require("./generated/UIEvent").interface;
exports.MouseEvent = require("./generated/MouseEvent").interface;
exports.KeyboardEvent = require("./generated/KeyboardEvent").interface;
exports.TouchEvent = require("./generated/TouchEvent").interface;
exports.ProgressEvent = require("./generated/ProgressEvent").interface;
exports.EventTarget = require("./generated/EventTarget").interface;
exports.Location = require("./generated/Location").interface;
exports.History = require("./generated/History").interface;
exports.Blob = require("./generated/Blob").interface;
exports.File = require("./generated/File").interface;
exports.FileList = require("./generated/FileList").interface;
exports.DOMParser = require("./generated/DOMParser").interface;
exports.FormData = require("./generated/FormData").interface;
require("./register-elements")(exports);
// These need to be cleaned up...
require("../level2/style")(exports);
require("../level3/xpath")(exports);
// These are OK but need migration to webidl2js eventually.
require("./html-collection")(exports);
require("./node-filter")(exports);
require("./node-iterator")(exports);
require("./node-list")(exports);
require("./xmlhttprequest-event-target")(exports);
require("./xmlhttprequest-upload")(exports);
exports.DOMTokenList = require("./dom-token-list").DOMTokenList;
exports.URL = require("whatwg-url").URL;
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const hasOwnProp = Object.prototype.hasOwnProperty;
const namedPropertiesTracker = require("../named-properties-tracker");
const NODE_TYPE = require("./node-type");
const createHTMLCollection = require("./html-collection").create;
const treeOrderSorter = require("../utils").treeOrderSorter;
const idlUtils = require("./generated/utils");
function isNamedPropertyElement(element) {
// (for the name attribute)
// use hasOwnProperty to make sure contentWindow comes from the prototype,
// and is not set directly on the node by a script.
if ("contentWindow" in element && !hasOwnProp.call(element, "contentWindow")) {
return true;
}
switch (element.nodeName) {
case "A":
case "APPLET":
case "AREA":
case "EMBED":
case "FORM":
case "FRAMESET":
case "IMG":
case "OBJECT":
return true;
default:
return false;
}
}
function namedPropertyResolver(HTMLCollection, window, name, values) {
function getResult() {
const results = [];
for (const node of values().keys()) {
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE) {
continue;
}
if (node.getAttribute("id") === name) {
results.push(node);
} else if (node.getAttribute("name") === name && isNamedPropertyElement(node)) {
results.push(node);
}
}
results.sort(treeOrderSorter);
return results;
}
const document = window._document;
const objects = createHTMLCollection(idlUtils.implForWrapper(document.documentElement), getResult);
const length = objects.length;
for (let i = 0; i < length; ++i) {
const node = objects[i];
if ("contentWindow" in node && !hasOwnProp.call(node, "contentWindow") &&
node.getAttribute("name") === name) {
return node.contentWindow;
}
}
if (length === 0) {
return undefined;
}
if (length === 1) {
return objects[0];
}
return objects;
}
exports.initializeWindow = function (window, HTMLCollection) {
namedPropertiesTracker.create(window, namedPropertyResolver.bind(null, HTMLCollection));
};
exports.elementAttributeModified = function (element, name, value, oldValue) {
if (!element._attached) {
return;
}
const useName = isNamedPropertyElement(element);
if (name === "id" || (name === "name" && useName)) {
const tracker = namedPropertiesTracker.get(element._ownerDocument._global);
// (tracker will be null if the document has no Window)
if (tracker) {
if (name === "id" && (!useName || element.getAttribute("name") !== oldValue)) {
tracker.untrack(oldValue, element);
}
if (name === "name" && element.getAttribute("id") !== oldValue) {
tracker.untrack(oldValue, element);
}
tracker.track(value, element);
}
}
};
exports.nodeAttachedToDocument = function (node) {
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE) {
return;
}
const tracker = namedPropertiesTracker.get(node._ownerDocument._global);
if (!tracker) {
return;
}
tracker.track(node.getAttribute("id"), node);
if (isNamedPropertyElement(node)) {
tracker.track(node.getAttribute("name"), node);
}
};
exports.nodeDetachedFromDocument = function (node) {
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE) {
return;
}
const tracker = namedPropertiesTracker.get(node._ownerDocument._global);
if (!tracker) {
return;
}
tracker.untrack(node.getAttribute("id"), node);
if (isNamedPropertyElement(node)) {
tracker.untrack(node.getAttribute("name"), node);
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 | 1 | "use strict";
module.exports = Object.freeze({
DOCUMENT_POSITION_DISCONNECTED: 1,
DOCUMENT_POSITION_PRECEDING: 2,
DOCUMENT_POSITION_FOLLOWING: 4,
DOCUMENT_POSITION_CONTAINS: 8,
DOCUMENT_POSITION_CONTAINED_BY: 16,
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32
});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 1 1 1 1 1 | "use strict";
const addConstants = require("../utils").addConstants;
module.exports = function (core) {
// https://dom.spec.whatwg.org/#interface-nodefilter
core.NodeFilter = function () {
throw new TypeError("Illegal constructor");
};
/**
* Returns an unsigned short that will be used to tell if a given Node must
* be accepted or not by the NodeIterator or TreeWalker iteration
* algorithm. This method is expected to be written by the user of a
* NodeFilter.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/NodeFilter
* @interface
*
* @param {Node} node DOM Node
* @return {FILTER_ACCEPT|FILTER_REJECT|FILTER_SKIP}
*/
core.NodeFilter.acceptNode = function (/* node */) {
throw new Error("This method is expected to be written by the user of a NodeFilter.");
};
addConstants(core.NodeFilter, {
// Constants for whatToShow
SHOW_ALL: 0xFFFFFFFF,
SHOW_ELEMENT: 0x00000001,
SHOW_ATTRIBUTE: 0x00000002,
SHOW_TEXT: 0x00000004,
SHOW_CDATA_SECTION: 0x00000008,
SHOW_ENTITY_REFERENCE: 0x00000010,
SHOW_ENTITY: 0x00000020,
SHOW_PROCESSING_INSTRUCTION: 0x00000040,
SHOW_COMMENT: 0x00000080,
SHOW_DOCUMENT: 0x00000100,
SHOW_DOCUMENT_TYPE: 0x00000200,
SHOW_DOCUMENT_FRAGMENT: 0x00000400,
SHOW_NOTATION: 0x00000800,
// Constants returned by acceptNode
FILTER_ACCEPT: 1,
FILTER_REJECT: 2,
FILTER_SKIP: 3
});
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const idlUtils = require("./generated/utils");
const domSymbolTree = require("./helpers/internal-constants").domSymbolTree;
const defineGetter = require("../utils").defineGetter;
const INTERNAL = Symbol("NodeIterator internal");
const DocumentImpl = require("./nodes/Document-impl").implementation;
module.exports = function (core) {
// https://dom.spec.whatwg.org/#interface-nodeiterator
function NodeIteratorInternal(document, root, whatToShow, filter) {
this.active = true;
this.document = document;
this.root = root;
this.referenceNode = root;
this.pointerBeforeReferenceNode = true;
this.whatToShow = whatToShow;
this.filter = filter;
}
NodeIteratorInternal.prototype.throwIfNotActive = function () {
// (only thrown for getters/methods that are affected by removing steps)
if (!this.active) {
throw Error("This NodeIterator is no longer active. " +
"More than " + this.document._activeNodeIteratorsMax +
" iterators are being used concurrently. " +
"You can increase the 'concurrentNodeIterators' option to " +
"make this error go away."
);
// Alternatively, you can pester Ecma to add support for weak references,
// the DOM standard assumes the implementor has control over object life cycles.
}
};
NodeIteratorInternal.prototype.traverse = function (next) {
let node = this.referenceNode;
let beforeNode = this.pointerBeforeReferenceNode;
do {
if (next) {
if (!beforeNode) {
node = domSymbolTree.following(node, { root: this.root });
if (!node) {
return null;
}
}
beforeNode = false;
} else { // previous
if (beforeNode) {
node = domSymbolTree.preceding(node, { root: this.root });
if (!node) {
return null;
}
}
beforeNode = true;
}
}
while (this.filterNode(node) !== core.NodeFilter.FILTER_ACCEPT);
this.pointerBeforeReferenceNode = beforeNode;
this.referenceNode = node;
return node;
};
NodeIteratorInternal.prototype.filterNode = function (node) {
const n = node.nodeType - 1;
if (!(this.whatToShow & (1 << n))) {
return core.NodeFilter.FILTER_SKIP;
}
let ret = core.NodeFilter.FILTER_ACCEPT;
const filter = this.filter;
if (typeof filter === "function") {
ret = filter(node);
} else if (filter && typeof filter.acceptNode === "function") {
ret = filter.acceptNode(node);
}
if (ret === true) {
return core.NodeFilter.FILTER_ACCEPT;
} else if (ret === false) {
return core.NodeFilter.FILTER_REJECT;
}
return ret;
};
NodeIteratorInternal.prototype.runRemovingSteps = function (oldNode, oldParent, oldPreviousSibling) {
if (oldNode.contains(this.root)) {
return;
}
// If oldNode is not an inclusive ancestor of the referenceNode
// attribute value, terminate these steps.
if (!oldNode.contains(this.referenceNode)) {
return;
}
if (this.pointerBeforeReferenceNode) {
// Let nextSibling be oldPreviousSibling’s next sibling, if oldPreviousSibling is non-null,
// and oldParent’s first child otherwise.
const nextSibling = oldPreviousSibling ?
oldPreviousSibling.nextSibling :
oldParent.firstChild;
// If nextSibling is non-null, set the referenceNode attribute to nextSibling
// and terminate these steps.
if (nextSibling) {
this.referenceNode = nextSibling;
return;
}
// Let next be the first node following oldParent (excluding any children of oldParent).
const next = domSymbolTree.following(oldParent, { skipChildren: true });
// If root is an inclusive ancestor of next, set the referenceNode
// attribute to next and terminate these steps.
if (this.root.contains(next)) {
this.referenceNode = next;
return;
}
// Otherwise, set the pointerBeforeReferenceNode attribute to false.
this.pointerBeforeReferenceNode = false;
// Note: Steps are not terminated here.
}
// Set the referenceNode attribute to the last inclusive descendant in tree order of oldPreviousSibling,
// if oldPreviousSibling is non-null, and to oldParent otherwise.
this.referenceNode = oldPreviousSibling ?
domSymbolTree.lastInclusiveDescendant(oldPreviousSibling) :
oldParent;
};
DocumentImpl._removingSteps.push((document, oldNode, oldParent, oldPreviousSibling) => {
for (let i = 0; i < document._activeNodeIterators.length; ++i) {
const internal = document._activeNodeIterators[i];
internal.runRemovingSteps(oldNode, oldParent, oldPreviousSibling);
}
});
core.Document.prototype.createNodeIterator = function (root, whatToShow, filter) {
if (!root) {
throw new TypeError("Not enough arguments to Document.createNodeIterator.");
}
root = idlUtils.implForWrapper(root);
if (filter === undefined) {
filter = null;
}
if (filter !== null &&
typeof filter !== "function" &&
typeof filter.acceptNode !== "function") {
throw new TypeError("Argument 3 of Document.createNodeIterator should be a function or implement NodeFilter.");
}
const document = root._ownerDocument;
whatToShow = whatToShow === undefined ?
core.NodeFilter.SHOW_ALL :
(whatToShow & core.NodeFilter.SHOW_ALL) >>> 0; // >>> makes sure the result is unsigned
filter = filter || null;
const it = Object.create(core.NodeIterator.prototype);
const internal = new NodeIteratorInternal(document, root, whatToShow, filter);
it[INTERNAL] = internal;
document._activeNodeIterators.push(internal);
while (document._activeNodeIterators.length > document._activeNodeIteratorsMax) {
const internalOther = document._activeNodeIterators.shift();
internalOther.active = false;
}
return it;
};
core.NodeIterator = function NodeIterator() {
throw new TypeError("Illegal constructor");
};
defineGetter(core.NodeIterator.prototype, "root", function () {
return idlUtils.wrapperForImpl(this[INTERNAL].root);
});
defineGetter(core.NodeIterator.prototype, "referenceNode", function () {
const internal = this[INTERNAL];
internal.throwIfNotActive();
return idlUtils.wrapperForImpl(internal.referenceNode);
});
defineGetter(core.NodeIterator.prototype, "pointerBeforeReferenceNode", function () {
const internal = this[INTERNAL];
internal.throwIfNotActive();
return internal.pointerBeforeReferenceNode;
});
defineGetter(core.NodeIterator.prototype, "whatToShow", function () {
return this[INTERNAL].whatToShow;
});
defineGetter(core.NodeIterator.prototype, "filter", function () {
return this[INTERNAL].filter;
});
core.NodeIterator.prototype.previousNode = function () {
const internal = this[INTERNAL];
internal.throwIfNotActive();
return idlUtils.wrapperForImpl(internal.traverse(false));
};
core.NodeIterator.prototype.nextNode = function () {
const internal = this[INTERNAL];
internal.throwIfNotActive();
return idlUtils.wrapperForImpl(internal.traverse(true));
};
core.NodeIterator.prototype.detach = function () {
// noop
};
core.NodeIterator.prototype.toString = function () {
return "[object NodeIterator]";
};
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const lengthFromProperties = require("../utils").lengthFromProperties;
const idlUtils = require("./generated/utils");
const privates = Symbol("NodeList internal slots");
class NodeList {
constructor(secret, config) {
if (secret !== privates) {
throw new TypeError("Invalid constructor");
}
if (config.nodes) {
this[privates] = {
isLive: false,
length: config.nodes.length
};
for (let i = 0; i < config.nodes.length; ++i) {
this[i] = config.nodes[i];
}
} else {
this[privates] = {
isLive: true,
element: config.element,
query: config.query,
snapshot: undefined,
length: 0,
version: -1
};
updateNodeList(this);
}
}
get length() {
updateNodeList(this);
return this[privates].length;
}
item(index) {
updateNodeList(this);
return this[index] || null;
}
// TODO reimplement this in webidl2js so these become more per-spec
* keys() {
updateNodeList(this);
const length = this[privates].length;
for (let i = 0; i < length; ++i) {
yield i;
}
}
* entries() {
updateNodeList(this);
const length = this[privates].length;
for (let i = 0; i < length; ++i) {
yield [i, this[i]];
}
}
forEach(callback) {
const thisArg = arguments[1]; // TODO Node v6: use default arguments
let values = Array.from(this);
let i = 0;
while (i < values.length) {
callback.call(thisArg, values[i], i, this);
values = Array.from(this);
++i;
}
}
}
NodeList.prototype[Symbol.iterator] = NodeList.prototype.values = Array.prototype[Symbol.iterator];
function updateNodeList(nodeList) {
if (nodeList[privates].isLive) {
if (nodeList[privates].version < nodeList[privates].element._version) {
nodeList[privates].snapshot = nodeList[privates].query();
resetNodeListTo(nodeList, nodeList[privates].snapshot);
nodeList[privates].version = nodeList[privates].element._version;
}
} else {
nodeList[privates].length = lengthFromProperties(nodeList);
}
}
function resetNodeListTo(nodeList, nodes) {
const startingLength = lengthFromProperties(nodeList);
for (let i = 0; i < startingLength; ++i) {
delete nodeList[i];
}
for (let i = 0; i < nodes.length; ++i) {
const wrapper = idlUtils.wrapperForImpl(nodes[i]);
nodeList[i] = wrapper ? wrapper : nodes[i];
}
nodeList[privates].length = nodes.length;
}
module.exports = function (core) {
core.NodeList = NodeList;
};
module.exports.createLive = function (element, query) {
return new NodeList(privates, { element, query });
};
module.exports.createStatic = function (nodes) {
return new NodeList(privates, { nodes });
};
module.exports.update = updateNodeList;
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1 | "use strict";
module.exports = Object.freeze({
ELEMENT_NODE: 1,
ATTRIBUTE_NODE: 2, // historical
TEXT_NODE: 3,
CDATA_SECTION_NODE: 4, // historical
ENTITY_REFERENCE_NODE: 5, // historical
ENTITY_NODE: 6, // historical
PROCESSING_INSTRUCTION_NODE: 7,
COMMENT_NODE: 8,
DOCUMENT_NODE: 9,
DOCUMENT_TYPE_NODE: 10,
DOCUMENT_FRAGMENT_NODE: 11,
NOTATION_NODE: 12 // historical
});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const attributes = require("./attributes");
const cloningSteps = require("./helpers/internal-constants").cloningSteps;
const domSymbolTree = require("./helpers/internal-constants").domSymbolTree;
const NODE_TYPE = require("./node-type");
const orderedSetParser = require("./helpers/ordered-set-parser");
const createHTMLCollection = require("./html-collection").create;
const domTokenListContains = require("./dom-token-list").contains;
module.exports.clone = function (core, node, document, cloneChildren) {
if (document === undefined) {
document = node._ownerDocument;
}
let copy;
switch (node.nodeType) {
case NODE_TYPE.DOCUMENT_NODE:
// TODO: just use Document when we eliminate the difference between Document and HTMLDocument.
if (node.contentType === "text/html") { // need to differentiate due to parsing mode
copy = document.implementation.createHTMLDocument();
copy.removeChild(copy.documentElement); // ;_;
} else {
copy = document.implementation.createDocument("", "", null);
}
document = copy;
break;
case NODE_TYPE.DOCUMENT_TYPE_NODE:
copy = document.implementation.createDocumentType(node.name, node.publicId, node.systemId);
break;
case NODE_TYPE.ELEMENT_NODE:
copy = document._createElementWithCorrectElementInterface(node._localName, node._namespaceURI);
copy._namespaceURI = node._namespaceURI;
copy._prefix = node._prefix;
copy._localName = node._localName;
attributes.copyAttributeList(node, copy);
break;
case NODE_TYPE.TEXT_NODE:
copy = document.createTextNode(node._data);
break;
case NODE_TYPE.CDATA_SECTION_NODE:
copy = document.createCDATASection(node._data);
break;
case NODE_TYPE.COMMENT_NODE:
copy = document.createComment(node._data);
break;
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
copy = document.createProcessingInstruction(node.target, node._data);
break;
case NODE_TYPE.DOCUMENT_FRAGMENT_NODE:
copy = document.createDocumentFragment();
break;
}
if (node[cloningSteps]) {
node[cloningSteps](copy, node, document, cloneChildren);
}
if (cloneChildren) {
for (const child of domSymbolTree.childrenIterator(node)) {
const childCopy = module.exports.clone(core, child, document, true);
copy.appendChild(childCopy);
}
}
return copy;
};
// For the following, memoization is not applied here since the memoized results are stored on `this`.
module.exports.listOfElementsWithClassNames = (classNames, root) => {
// https://dom.spec.whatwg.org/#concept-getElementsByClassName
const classes = orderedSetParser(classNames);
if (classes.size === 0) {
return createHTMLCollection(root, () => []);
}
return createHTMLCollection(root, () => {
const isQuirksMode = root._ownerDocument.compatMode === "BackCompat";
return domSymbolTree.treeToArray(root, { filter(node) {
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) {
return false;
}
for (const className of classes) {
if (!domTokenListContains(node.classList, className, { caseInsensitive: isQuirksMode })) {
return false;
}
}
return true;
} });
});
};
module.exports.listOfElementsWithQualifiedName = (qualifiedName, root) => {
// https://dom.spec.whatwg.org/#concept-getelementsbytagname
if (qualifiedName === "*") {
return createHTMLCollection(root, () => {
return domSymbolTree.treeToArray(root, { filter(node) {
return node.nodeType === NODE_TYPE.ELEMENT_NODE && node !== root;
} });
});
}
if (root._ownerDocument._parsingMode === "html") {
const lowerQualifiedName = qualifiedName.toLowerCase();
return createHTMLCollection(root, () => {
return domSymbolTree.treeToArray(root, { filter(node) {
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) {
return false;
}
if (node._namespaceURI === "http://www.w3.org/1999/xhtml") {
return node._qualifiedName === lowerQualifiedName;
}
return node._qualifiedName === qualifiedName;
} });
});
}
return createHTMLCollection(root, () => {
return domSymbolTree.treeToArray(root, { filter(node) {
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) {
return false;
}
return node._qualifiedName === qualifiedName;
} });
});
};
module.exports.listOfElementsWithNamespaceAndLocalName = (namespace, localName, root) => {
// https://dom.spec.whatwg.org/#concept-getelementsbytagnamens
if (namespace === "") {
namespace = null;
}
if (namespace === "*" && localName === "*") {
return createHTMLCollection(root, () => {
return domSymbolTree.treeToArray(root, { filter(node) {
return node.nodeType === NODE_TYPE.ELEMENT_NODE && node !== root;
} });
});
}
if (namespace === "*") {
return createHTMLCollection(root, () => {
return domSymbolTree.treeToArray(root, { filter(node) {
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) {
return false;
}
return node._localName === localName;
} });
});
}
if (localName === "*") {
return createHTMLCollection(root, () => {
return domSymbolTree.treeToArray(root, { filter(node) {
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) {
return false;
}
return node._namespaceURI === namespace;
} });
});
}
return createHTMLCollection(root, () => {
return domSymbolTree.treeToArray(root, { filter(node) {
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) {
return false;
}
return node._localName === localName && node._namespaceURI === namespace;
} });
});
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 1 1 1 | "use strict";
const isValidTargetOrigin = require("../utils").isValidTargetOrigin;
const DOMException = require("../web-idl/DOMException");
module.exports = function (message, targetOrigin) {
if (arguments.length < 2) {
throw new TypeError("'postMessage' requires 2 arguments: 'message' and 'targetOrigin'");
}
targetOrigin = String(targetOrigin);
if (!isValidTargetOrigin(targetOrigin)) {
throw new DOMException(DOMException.SYNTAX_ERR, "Failed to execute 'postMessage' on 'Window': " +
"Invalid target origin '" + targetOrigin + "' in a call to 'postMessage'.");
}
// TODO: targetOrigin === '/' - requires reference to source window
// See https://github.com/tmpvar/jsdom/pull/1140#issuecomment-111587499
if (targetOrigin !== "*" && targetOrigin !== this.origin) {
return;
}
// TODO: event.source - requires reference to source window
// TODO: event.origin - requires reference to source window
// TODO: event.ports
// TODO: event.data - structured clone message - requires cloning DOM nodes
const event = new this.MessageEvent("message", {
data: message
});
event.initEvent("message", false, false);
setTimeout(() => {
this.dispatchEvent(event);
}, 0);
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | 1 1 1 1 70 70 70 70 76 | "use strict";
/* eslint global-require: 0 */
const DocumentImpl = require("./nodes/Document-impl.js");
const mappings = {
HTMLElement: {
file: require("./generated/HTMLElement.js"),
tags: []
},
HTMLAnchorElement: {
file: require("./generated/HTMLAnchorElement.js"),
tags: ["a"]
},
HTMLAppletElement: {
file: require("./generated/HTMLAppletElement.js"),
tags: ["applet"]
},
HTMLAreaElement: {
file: require("./generated/HTMLAreaElement.js"),
tags: ["area"]
},
HTMLAudioElement: {
file: require("./generated/HTMLAudioElement.js"),
tags: ["audio"]
},
HTMLBaseElement: {
file: require("./generated/HTMLBaseElement.js"),
tags: ["base"]
},
HTMLBodyElement: {
file: require("./generated/HTMLBodyElement.js"),
tags: ["body"]
},
HTMLBRElement: {
file: require("./generated/HTMLBRElement.js"),
tags: ["br"]
},
HTMLButtonElement: {
file: require("./generated/HTMLButtonElement.js"),
tags: ["button"]
},
HTMLCanvasElement: {
file: require("./generated/HTMLCanvasElement.js"),
tags: ["canvas"]
},
HTMLDataElement: {
file: require("./generated/HTMLDataElement.js"),
tags: ["data"]
},
HTMLDataListElement: {
file: require("./generated/HTMLDataListElement.js"),
tags: ["datalist"]
},
HTMLDialogElement: {
file: require("./generated/HTMLDialogElement.js"),
tags: ["dialog"]
},
HTMLDirectoryElement: {
file: require("./generated/HTMLDirectoryElement.js"),
tags: ["dir"]
},
HTMLDivElement: {
file: require("./generated/HTMLDivElement.js"),
tags: ["div"]
},
HTMLDListElement: {
file: require("./generated/HTMLDListElement.js"),
tags: ["dl"]
},
HTMLEmbedElement: {
file: require("./generated/HTMLEmbedElement.js"),
tags: ["embed"]
},
HTMLFieldSetElement: {
file: require("./generated/HTMLFieldSetElement.js"),
tags: ["fieldset"]
},
HTMLFontElement: {
file: require("./generated/HTMLFontElement.js"),
tags: ["font"]
},
HTMLFormElement: {
file: require("./generated/HTMLFormElement.js"),
tags: ["form"]
},
HTMLFrameElement: {
file: require("./generated/HTMLFrameElement.js"),
tags: ["frame"]
},
HTMLFrameSetElement: {
file: require("./generated/HTMLFrameSetElement.js"),
tags: ["frameset"]
},
HTMLHeadingElement: {
file: require("./generated/HTMLHeadingElement.js"),
tags: ["h1", "h2", "h3", "h4", "h5", "h6"]
},
HTMLHeadElement: {
file: require("./generated/HTMLHeadElement.js"),
tags: ["head"]
},
HTMLHRElement: {
file: require("./generated/HTMLHRElement.js"),
tags: ["hr"]
},
HTMLHtmlElement: {
file: require("./generated/HTMLHtmlElement.js"),
tags: ["html"]
},
HTMLIFrameElement: {
file: require("./generated/HTMLIFrameElement.js"),
tags: ["iframe"]
},
HTMLImageElement: {
file: require("./generated/HTMLImageElement.js"),
tags: ["img"]
},
HTMLInputElement: {
file: require("./generated/HTMLInputElement.js"),
tags: ["input"]
},
HTMLLabelElement: {
file: require("./generated/HTMLLabelElement.js"),
tags: ["label"]
},
HTMLLegendElement: {
file: require("./generated/HTMLLegendElement.js"),
tags: ["legend"]
},
HTMLLIElement: {
file: require("./generated/HTMLLIElement.js"),
tags: ["li"]
},
HTMLLinkElement: {
file: require("./generated/HTMLLinkElement.js"),
tags: ["link"]
},
HTMLMapElement: {
file: require("./generated/HTMLMapElement.js"),
tags: ["map"]
},
HTMLMediaElement: {
file: require("./generated/HTMLMediaElement.js"),
tags: []
},
HTMLMenuElement: {
file: require("./generated/HTMLMenuElement.js"),
tags: ["menu"]
},
HTMLMetaElement: {
file: require("./generated/HTMLMetaElement.js"),
tags: ["meta"]
},
HTMLMeterElement: {
file: require("./generated/HTMLMeterElement.js"),
tags: ["meter"]
},
HTMLModElement: {
file: require("./generated/HTMLModElement.js"),
tags: ["del", "ins"]
},
HTMLObjectElement: {
file: require("./generated/HTMLObjectElement.js"),
tags: ["object"]
},
HTMLOListElement: {
file: require("./generated/HTMLOListElement.js"),
tags: ["ol"]
},
HTMLOptGroupElement: {
file: require("./generated/HTMLOptGroupElement.js"),
tags: ["optgroup"]
},
HTMLOptionElement: {
file: require("./generated/HTMLOptionElement.js"),
tags: ["option"]
},
HTMLOutputElement: {
file: require("./generated/HTMLOutputElement.js"),
tags: ["output"]
},
HTMLParagraphElement: {
file: require("./generated/HTMLParagraphElement.js"),
tags: ["p"]
},
HTMLParamElement: {
file: require("./generated/HTMLParamElement.js"),
tags: ["param"]
},
HTMLPreElement: {
file: require("./generated/HTMLPreElement.js"),
tags: ["pre"]
},
HTMLProgressElement: {
file: require("./generated/HTMLProgressElement.js"),
tags: ["progress"]
},
HTMLQuoteElement: {
file: require("./generated/HTMLQuoteElement.js"),
tags: ["blockquote", "q"]
},
HTMLScriptElement: {
file: require("./generated/HTMLScriptElement.js"),
tags: ["script"]
},
HTMLSelectElement: {
file: require("./generated/HTMLSelectElement.js"),
tags: ["select"]
},
HTMLSourceElement: {
file: require("./generated/HTMLSourceElement.js"),
tags: ["source"]
},
HTMLSpanElement: {
file: require("./generated/HTMLSpanElement.js"),
tags: ["span"]
},
HTMLStyleElement: {
file: require("./generated/HTMLStyleElement.js"),
tags: ["style"]
},
HTMLTableCaptionElement: {
file: require("./generated/HTMLTableCaptionElement.js"),
tags: ["caption"]
},
HTMLTableCellElement: {
file: require("./generated/HTMLTableCellElement.js"),
tags: []
},
HTMLTableColElement: {
file: require("./generated/HTMLTableColElement.js"),
tags: ["col", "colgroup"]
},
HTMLTableDataCellElement: {
file: require("./generated/HTMLTableDataCellElement.js"),
tags: ["td"]
},
HTMLTableElement: {
file: require("./generated/HTMLTableElement.js"),
tags: ["table"]
},
HTMLTableHeaderCellElement: {
file: require("./generated/HTMLTableHeaderCellElement.js"),
tags: ["th"]
},
HTMLTimeElement: {
file: require("./generated/HTMLTimeElement.js"),
tags: ["time"]
},
HTMLTitleElement: {
file: require("./generated/HTMLTitleElement.js"),
tags: ["title"]
},
HTMLTableRowElement: {
file: require("./generated/HTMLTableRowElement.js"),
tags: ["tr"]
},
HTMLTableSectionElement: {
file: require("./generated/HTMLTableSectionElement.js"),
tags: ["thead", "tbody", "tfoot"]
},
HTMLTemplateElement: {
file: require("./generated/HTMLTemplateElement.js"),
tags: ["template"]
},
HTMLTextAreaElement: {
file: require("./generated/HTMLTextAreaElement.js"),
tags: ["textarea"]
},
HTMLTrackElement: {
file: require("./generated/HTMLTrackElement.js"),
tags: ["track"]
},
HTMLUListElement: {
file: require("./generated/HTMLUListElement.js"),
tags: ["ul"]
},
HTMLUnknownElement: {
file: require("./generated/HTMLUnknownElement.js"),
tags: []
},
HTMLVideoElement: {
file: require("./generated/HTMLVideoElement.js"),
tags: ["video"]
}
};
module.exports = core => {
for (const interfaceName of Object.keys(mappings)) {
const file = mappings[interfaceName].file;
const tags = mappings[interfaceName].tags;
core[interfaceName] = file.interface;
for (const tagName of tags) {
DocumentImpl.implementation.prototype._elementBuilders[tagName] = (document, elName) => {
return file.create([], {
core,
ownerDocument: document,
localName: elName || tagName.toUpperCase()
});
};
}
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const request = require("request");
const EventEmitter = require("events").EventEmitter;
const fs = require("fs");
const URL = require("whatwg-url").URL;
const utils = require("../utils");
const xhrSymbols = require("./xmlhttprequest-symbols");
function wrapCookieJarForRequest(cookieJar) {
const jarWrapper = request.jar();
jarWrapper._jar = cookieJar;
return jarWrapper;
}
function getRequestHeader(requestHeaders, header) {
const lcHeader = header.toLowerCase();
const keys = Object.keys(requestHeaders);
let n = keys.length;
while (n--) {
const key = keys[n];
if (key.toLowerCase() === lcHeader) {
return requestHeaders[key];
}
}
return null;
}
function updateRequestHeader(requestHeaders, header, newValue) {
const lcHeader = header.toLowerCase();
const keys = Object.keys(requestHeaders);
let n = keys.length;
while (n--) {
const key = keys[n];
if (key.toLowerCase() === lcHeader) {
requestHeaders[key] = newValue;
}
}
}
const simpleMethods = new Set(["GET", "HEAD", "POST"]);
const simpleHeaders = new Set(["accept", "accept-language", "content-language", "content-type"]);
exports.getRequestHeader = getRequestHeader;
exports.updateRequestHeader = updateRequestHeader;
exports.simpleHeaders = simpleHeaders;
// return a "request" client object or an event emitter matching the same behaviour for unsupported protocols
// the callback should be called with a "request" response object or an event emitter matching the same behaviour too
exports.createClient = function createClient(xhr) {
const flag = xhr[xhrSymbols.flag];
const properties = xhr[xhrSymbols.properties];
const urlObj = new URL(flag.uri);
const uri = urlObj.href;
const ucMethod = flag.method.toUpperCase();
const requestManager = flag.requestManager;
if (urlObj.protocol === "file:") {
const response = new EventEmitter();
response.statusCode = 200;
response.rawHeaders = [];
response.headers = {};
response.request = { uri: urlObj };
const filePath = urlObj.pathname
.replace(/^file:\/\//, "")
.replace(/^\/([a-z]):\//i, "$1:/")
.replace(/%20/g, " ");
const client = new EventEmitter();
const readableStream = fs.createReadStream(filePath, { encoding: null });
readableStream.on("data", chunk => {
response.emit("data", chunk);
client.emit("data", chunk);
});
readableStream.on("end", () => {
response.emit("end");
client.emit("end");
});
readableStream.on("error", err => {
response.emit("error", err);
client.emit("error", err);
});
client.abort = function () {
readableStream.destroy();
client.emit("abort");
};
if (requestManager) {
const req = {
abort() {
properties.abortError = true;
xhr.abort();
}
};
requestManager.add(req);
const rmReq = requestManager.remove.bind(requestManager, req);
client.on("abort", rmReq);
client.on("error", rmReq);
client.on("end", rmReq);
}
process.nextTick(() => client.emit("response", response));
return client;
}
if (urlObj.protocol === "data:") {
const response = new EventEmitter();
response.request = { uri: urlObj };
const client = new EventEmitter();
let buffer;
if (ucMethod === "GET") {
try {
const dataUrlContent = utils.parseDataUrl(uri);
buffer = dataUrlContent.buffer;
response.statusCode = 200;
response.rawHeaders = dataUrlContent.type ? ["Content-Type", dataUrlContent.type] : [];
response.headers = dataUrlContent.type ? { "content-type": dataUrlContent.type } : {};
} catch (err) {
process.nextTick(() => client.emit("error", err));
return client;
}
} else {
buffer = new Buffer("");
response.statusCode = 0;
response.rawHeaders = {};
response.headers = {};
}
client.abort = () => {
// do nothing
};
process.nextTick(() => {
client.emit("response", response);
process.nextTick(() => {
response.emit("data", buffer);
client.emit("data", buffer);
response.emit("end");
client.emit("end");
});
});
return client;
}
const requestHeaders = {};
for (const header in flag.requestHeaders) {
requestHeaders[header] = flag.requestHeaders[header];
}
if (getRequestHeader(flag.requestHeaders, "referer") === null) {
requestHeaders.Referer = flag.referrer;
}
if (getRequestHeader(flag.requestHeaders, "user-agent") === null) {
requestHeaders["User-Agent"] = flag.userAgent;
}
if (getRequestHeader(flag.requestHeaders, "accept-language") === null) {
requestHeaders["Accept-Language"] = "en";
}
if (getRequestHeader(flag.requestHeaders, "accept") === null) {
requestHeaders.Accept = "*/*";
}
const crossOrigin = flag.origin !== urlObj.origin;
if (crossOrigin) {
requestHeaders.Origin = flag.origin;
}
const options = {
uri,
method: flag.method,
headers: requestHeaders,
gzip: true,
maxRedirects: 21,
followAllRedirects: true,
encoding: null,
pool: flag.pool,
agentOptions: flag.agentOptions,
strictSSL: flag.strictSSL
};
if (flag.auth) {
options.auth = {
user: flag.auth.user || "",
pass: flag.auth.pass || "",
sendImmediately: false
};
}
if (flag.cookieJar && (!crossOrigin || flag.withCredentials)) {
options.jar = wrapCookieJarForRequest(flag.cookieJar);
}
if (flag.proxy) {
options.proxy = flag.proxy;
}
const body = flag.body;
const hasBody = body !== undefined &&
body !== null &&
body !== "" &&
!(ucMethod === "HEAD" || ucMethod === "GET");
if (hasBody && !flag.formData) {
options.body = body;
}
if (hasBody && getRequestHeader(flag.requestHeaders, "content-type") === null) {
requestHeaders["Content-Type"] = "text/plain;charset=UTF-8";
}
function doRequest() {
try {
const client = request(options);
if (hasBody && flag.formData) {
const form = client.form();
for (const entry of body) {
form.append(entry.name, entry.value, entry.options);
}
}
return client;
} catch (e) {
const client = new EventEmitter();
process.nextTick(() => client.emit("error", e));
return client;
}
}
let client;
const nonSimpleHeaders = Object.keys(flag.requestHeaders)
.filter(header => !simpleHeaders.has(header.toLowerCase()));
if (crossOrigin && (!simpleMethods.has(ucMethod) || nonSimpleHeaders.length > 0)) {
client = new EventEmitter();
const preflightRequestHeaders = [];
for (const header in requestHeaders) {
preflightRequestHeaders[header] = requestHeaders[header];
}
preflightRequestHeaders["Access-Control-Request-Method"] = flag.method;
if (nonSimpleHeaders.length > 0) {
preflightRequestHeaders["Access-Control-Request-Headers"] = nonSimpleHeaders.join(", ");
}
flag.preflight = true;
const preflightOptions = {
uri,
method: "OPTIONS",
headers: preflightRequestHeaders,
followRedirect: false,
encoding: null,
pool: flag.pool,
agentOptions: flag.agentOptions,
strictSSL: flag.strictSSL
};
if (flag.proxy) {
preflightOptions.proxy = flag.proxy;
}
const preflightClient = request(preflightOptions);
preflightClient.on("response", resp => {
if (resp.statusCode >= 200 && resp.statusCode <= 299) {
const realClient = doRequest();
realClient.on("response", res => client.emit("response", res));
realClient.on("data", chunk => client.emit("data", chunk));
realClient.on("end", () => client.emit("end"));
realClient.on("abort", () => client.emit("abort"));
realClient.on("request", req => {
client.headers = realClient.headers;
client.emit("request", req);
});
realClient.on("redirect", () => {
client.response = realClient.response;
client.emit("redirect");
});
realClient.on("error", err => client.emit("error", err));
client.abort = () => {
realClient.abort();
};
} else {
client.emit("error", new Error("Response for preflight has invalid HTTP status code " + resp.statusCode));
}
});
preflightClient.on("error", err => client.emit("error", err));
client.abort = () => {
preflightClient.abort();
};
} else {
client = doRequest();
}
if (requestManager) {
const req = {
abort() {
properties.abortError = true;
xhr.abort();
}
};
requestManager.add(req);
const rmReq = requestManager.remove.bind(requestManager, req);
client.on("abort", rmReq);
client.on("error", rmReq);
client.on("end", rmReq);
}
return client;
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1 1 1 1 1 | "use strict";
const EventTarget = require("./generated/EventTarget");
function XMLHttpRequestEventTarget() {
if (!(this instanceof XMLHttpRequestEventTarget)) {
throw new TypeError("DOM object constructor cannot be called as a function.");
}
EventTarget.setup(this);
this.onabort = null;
this.onerror = null;
this.onload = null;
this.onloadend = null;
this.onloadstart = null;
this.onprogress = null;
this.ontimeout = null;
}
XMLHttpRequestEventTarget.prototype = Object.create(EventTarget.interface.prototype);
module.exports = function (core) {
core.XMLHttpRequestEventTarget = XMLHttpRequestEventTarget;
};
|
| 1 2 3 4 5 6 | 1 1 | "use strict";
exports.flag = Symbol("flag");
exports.properties = Symbol("properties");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1 1 1 | "use strict";
module.exports = function (core) {
const XMLHttpRequestEventTarget = core.XMLHttpRequestEventTarget;
class XMLHttpRequestUpload extends XMLHttpRequestEventTarget {
constructor() {
super();
if (!(this instanceof XMLHttpRequestUpload)) {
throw new TypeError("DOM object constructor cannot be called as a function.");
}
}
}
core.XMLHttpRequestUpload = XMLHttpRequestUpload;
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const HTTP_STATUS_CODES = require("http").STATUS_CODES;
const spawnSync = require("child_process").spawnSync;
const URL = require("whatwg-url").URL;
const whatwgEncoding = require("whatwg-encoding");
const tough = require("tough-cookie");
const parseContentType = require("content-type-parser");
const xhrUtils = require("./xhr-utils");
const DOMException = require("../web-idl/DOMException");
const xhrSymbols = require("./xmlhttprequest-symbols");
const addConstants = require("../utils").addConstants;
const documentBaseURLSerialized = require("./helpers/document-base-url").documentBaseURLSerialized;
const idlUtils = require("./generated/utils");
const Document = require("./generated/Document");
const Blob = require("./generated/Blob");
const domToHtml = require("../browser/domtohtml").domToHtml;
const syncWorkerFile = require.resolve ? require.resolve("./xhr-sync-worker.js") : null;
const tokenRegexp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
const headerListSeparatorRegexp = /,[ \t]*/;
const fieldValueRegexp = /^[ \t]*(?:[\x21-\x7E\x80-\xFF](?:[ \t][\x21-\x7E\x80-\xFF])?)*[ \t]*$/;
const forbiddenRequestHeaders = new Set([
"accept-charset",
"accept-encoding",
"access-control-request-headers",
"access-control-request-method",
"connection",
"content-length",
"cookie",
"cookie2",
"date",
"dnt",
"expect",
"host",
"keep-alive",
"origin",
"referer",
"te",
"trailer",
"transfer-encoding",
"upgrade",
"via"
]);
const forbiddenResponseHeaders = new Set([
"set-cookie",
"set-cookie2"
]);
const uniqueResponseHeaders = new Set([
"content-type",
"content-length",
"user-agent",
"referer",
"host",
"authorization",
"proxy-authorization",
"if-modified-since",
"if-unmodified-since",
"from",
"location",
"max-forwards"
]);
const corsSafeResponseHeaders = new Set([
"cache-control",
"content-language",
"content-type",
"expires",
"last-modified",
"pragma"
]);
const allowedRequestMethods = new Set(["OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE"]);
const forbiddenRequestMethods = new Set(["TRACK", "TRACE", "CONNECT"]);
const XMLHttpRequestResponseType = new Set([
"",
"arraybuffer",
"blob",
"document",
"json",
"text"
]);
const simpleHeaders = xhrUtils.simpleHeaders;
const redirectStatuses = new Set([301, 302, 303, 307, 308]);
module.exports = function createXMLHttpRequest(window) {
const Event = window.Event;
const ProgressEvent = window.ProgressEvent;
const FormData = window.FormData;
const XMLHttpRequestEventTarget = window.XMLHttpRequestEventTarget;
const XMLHttpRequestUpload = window.XMLHttpRequestUpload;
class XMLHttpRequest extends XMLHttpRequestEventTarget {
constructor() {
super();
if (!(this instanceof XMLHttpRequest)) {
throw new TypeError("DOM object constructor cannot be called as a function.");
}
this.upload = new XMLHttpRequestUpload();
this.upload._ownerDocument = window.document;
this[xhrSymbols.flag] = {
synchronous: false,
withCredentials: false,
mimeType: null,
auth: null,
method: undefined,
responseType: "",
requestHeaders: {},
referrer: this._ownerDocument.URL,
uri: "",
timeout: 0,
body: undefined,
formData: false,
preflight: false,
requestManager: this._ownerDocument._requestManager,
pool: this._ownerDocument._pool,
agentOptions: this._ownerDocument._agentOptions,
strictSSL: this._ownerDocument._strictSSL,
proxy: this._ownerDocument._proxy,
cookieJar: this._ownerDocument._cookieJar,
encoding: this._ownerDocument._encoding,
origin: this._ownerDocument.origin,
userAgent: this._ownerDocument._defaultView.navigator.userAgent
};
this[xhrSymbols.properties] = {
beforeSend: false,
send: false,
timeoutStart: 0,
timeoutId: 0,
timeoutFn: null,
client: null,
responseHeaders: {},
filteredResponseHeaders: [],
responseBuffer: null,
responseCache: null,
responseTextCache: null,
responseXMLCache: null,
responseURL: "",
readyState: XMLHttpRequest.UNSENT,
status: 0,
statusText: "",
error: "",
uploadComplete: true,
abortError: false,
cookieJar: this._ownerDocument._cookieJar
};
this.onreadystatechange = null;
}
get readyState() {
return this[xhrSymbols.properties].readyState;
}
get status() {
return this[xhrSymbols.properties].status;
}
get statusText() {
return this[xhrSymbols.properties].statusText;
}
get responseType() {
return this[xhrSymbols.flag].responseType;
}
set responseType(responseType) {
const flag = this[xhrSymbols.flag];
if (this.readyState === XMLHttpRequest.LOADING || this.readyState === XMLHttpRequest.DONE) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
if (this.readyState === XMLHttpRequest.OPENED && flag.synchronous) {
throw new DOMException(DOMException.INVALID_ACCESS_ERR);
}
if (!XMLHttpRequestResponseType.has(responseType)) {
responseType = "";
}
flag.responseType = responseType;
}
get response() {
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
if (properties.responseCache) {
return properties.responseCache;
}
let res = "";
switch (this.responseType) {
case "":
case "text": {
res = this.responseText;
break;
}
case "arraybuffer": {
if (!properties.responseBuffer) {
return null;
}
res = (new Uint8Array(properties.responseBuffer)).buffer;
break;
}
case "blob": {
if (!properties.responseBuffer) {
return null;
}
const contentType = getContentType(this);
res = Blob.create([[new Uint8Array(properties.responseBuffer)], {
type: contentType && contentType.toString() || ""
}]);
break;
}
case "document": {
res = this.responseXML;
break;
}
case "json": {
if (this.readyState !== XMLHttpRequest.DONE || !properties.responseBuffer) {
res = null;
}
const contentType = getContentType(this);
const fallbackEncoding = whatwgEncoding.labelToName(
contentType && contentType.get("charset") || flag.encoding);
const jsonStr = whatwgEncoding.decode(properties.responseBuffer, fallbackEncoding);
try {
res = JSON.parse(jsonStr);
} catch (e) {
res = null;
}
break;
}
}
properties.responseCache = res;
return res;
}
get responseText() {
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
if (this.responseType !== "" && this.responseType !== "text") {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
if (this.readyState !== XMLHttpRequest.LOADING && this.readyState !== XMLHttpRequest.DONE) {
return "";
}
if (properties.responseTextCache) {
return properties.responseTextCache;
}
const responseBuffer = properties.responseBuffer;
if (!responseBuffer) {
return "";
}
const contentType = getContentType(this);
const fallbackEncoding = whatwgEncoding.labelToName(contentType && contentType.get("charset") || flag.encoding);
const res = whatwgEncoding.decode(responseBuffer, fallbackEncoding);
properties.responseTextCache = res;
return res;
}
get responseXML() {
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
if (this.responseType !== "" && this.responseType !== "document") {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
if (this.readyState !== XMLHttpRequest.DONE) {
return null;
}
if (properties.responseXMLCache) {
return properties.responseXMLCache;
}
const responseBuffer = properties.responseBuffer;
if (!responseBuffer) {
return null;
}
const contentType = getContentType(this);
let isHTML = false;
let isXML = false;
if (contentType) {
isHTML = contentType.isHTML();
isXML = contentType.isXML();
if (!isXML && !isHTML) {
return null;
}
}
const encoding = whatwgEncoding.getBOMEncoding(responseBuffer) ||
whatwgEncoding.labelToName(contentType && contentType.get("charset") || flag.encoding);
const resText = whatwgEncoding.decode(responseBuffer, encoding);
if (!resText) {
return null;
}
if (this.responseType === "" && isHTML) {
return null;
}
const res = Document.create([], { core: window._core, options: {
url: flag.uri,
lastModified: new Date(getResponseHeader(this, "last-modified")),
parsingMode: isHTML ? "html" : "xml",
cookieJar: { setCookieSync: () => undefined, getCookieStringSync: () => "" },
encoding
} });
const resImpl = idlUtils.implForWrapper(res);
try {
resImpl._htmlToDom.appendHtmlToDocument(resText, resImpl);
} catch (e) {
properties.responseXMLCache = null;
return null;
}
res.close();
properties.responseXMLCache = res;
return res;
}
get responseURL() {
return this[xhrSymbols.properties].responseURL;
}
get timeout() {
return this[xhrSymbols.flag].timeout;
}
set timeout(val) {
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
if (flag.synchronous) {
throw new DOMException(DOMException.INVALID_ACCESS_ERR);
}
flag.timeout = val;
clearTimeout(properties.timeoutId);
if (val > 0 && properties.timeoutFn) {
properties.timeoutId = setTimeout(
properties.timeoutFn,
Math.max(0, val - ((new Date()).getTime() - properties.timeoutStart))
);
} else {
properties.timeoutFn = null;
properties.timeoutStart = 0;
}
}
get withCredentials() {
return this[xhrSymbols.flag].withCredentials;
}
set withCredentials(val) {
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
if (!(this.readyState === XMLHttpRequest.UNSENT || this.readyState === XMLHttpRequest.OPENED)) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
if (properties.send) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
flag.withCredentials = val;
}
abort() {
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
// Terminate the request
clearTimeout(properties.timeoutId);
properties.timeoutFn = null;
properties.timeoutStart = 0;
const client = properties.client;
if (client) {
client.abort();
properties.client = null;
}
if ((this.readyState === XMLHttpRequest.OPENED && properties.send) ||
this.readyState === XMLHttpRequest.HEADERS_RECEIVED ||
this.readyState === XMLHttpRequest.LOADING) {
// Run the request error steps for event abort
properties.readyState = XMLHttpRequest.DONE;
properties.send = false;
properties.status = 0;
properties.statusText = "";
properties.responseCache = properties.responseTextCache = properties.responseXMLCache = null;
if (flag.synchronous) {
throw new DOMException(DOMException.ABORT_ERR);
}
this.dispatchEvent(new Event("readystatechange"));
// TODO: spec says this should only be checking upload complete flag?
if (!(flag.method === "HEAD" || flag.method === "GET")) {
properties.uploadComplete = true;
// TODO upload listener
this.upload.dispatchEvent(new ProgressEvent("abort"));
if (properties.abortError) {
// TODO document what this is about (here and below)
this.upload.dispatchEvent(new ProgressEvent("error"));
}
this.upload.dispatchEvent(new ProgressEvent("loadend"));
}
this.dispatchEvent(new ProgressEvent("abort"));
if (properties.abortError) {
this.dispatchEvent(new ProgressEvent("error"));
}
this.dispatchEvent(new ProgressEvent("loadend"));
}
if (this.readyState === XMLHttpRequest.DONE) {
properties.readyState = XMLHttpRequest.UNSENT;
properties.status = 0;
properties.statusText = "";
properties.responseCache = properties.responseTextCache = properties.responseXMLCache = null;
}
}
getAllResponseHeaders() {
const properties = this[xhrSymbols.properties];
const readyState = this.readyState;
if (readyState === XMLHttpRequest.UNSENT || readyState === XMLHttpRequest.OPENED) {
return "";
}
return Object.keys(properties.responseHeaders)
.filter(key => properties.filteredResponseHeaders.indexOf(key) === -1)
.map(key => [key, properties.responseHeaders[key]].join(": ")).join("\r\n");
}
getResponseHeader(header) {
const properties = this[xhrSymbols.properties];
const readyState = this.readyState;
if (readyState === XMLHttpRequest.UNSENT || readyState === XMLHttpRequest.OPENED) {
return null;
}
const lcHeader = toByteString(header).toLowerCase();
if (properties.filteredResponseHeaders.find(filtered => lcHeader === filtered.toLowerCase())) {
return null;
}
return getResponseHeader(this, lcHeader);
}
open(method, uri, asynchronous, user, password) {
if (!this._ownerDocument) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
const argumentCount = arguments.length;
if (argumentCount < 2) {
throw new TypeError("Not enought arguments");
}
method = toByteString(method);
if (!tokenRegexp.test(method)) {
throw new DOMException(DOMException.SYNTAX_ERR);
}
const upperCaseMethod = method.toUpperCase();
if (forbiddenRequestMethods.has(upperCaseMethod)) {
throw new DOMException(DOMException.SECURITY_ERR);
}
const client = properties.client;
if (client && typeof client.abort === "function") {
client.abort();
}
if (allowedRequestMethods.has(upperCaseMethod)) {
method = upperCaseMethod;
}
if (typeof asynchronous !== "undefined") {
flag.synchronous = !asynchronous;
} else {
flag.synchronous = false;
}
if (flag.responseType && flag.synchronous) {
throw new DOMException(DOMException.INVALID_ACCESS_ERR);
}
if (flag.synchronous && flag.timeout) {
throw new DOMException(DOMException.INVALID_ACCESS_ERR);
}
flag.method = method;
let urlObj;
try {
urlObj = new URL(uri, documentBaseURLSerialized(this._ownerDocument));
} catch (e) {
throw new DOMException(DOMException.SYNTAX_ERR);
}
if (user || (password && !urlObj.username)) {
flag.auth = {
user,
pass: password
};
urlObj.username = "";
urlObj.password = "";
}
flag.uri = urlObj.href;
flag.requestHeaders = {};
flag.preflight = false;
properties.send = false;
properties.requestBuffer = null;
properties.requestCache = null;
properties.abortError = false;
properties.responseURL = "";
readyStateChange(this, XMLHttpRequest.OPENED);
}
overrideMimeType(mime) {
const readyState = this.readyState;
if (readyState === XMLHttpRequest.LOADING || readyState === XMLHttpRequest.DONE) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
if (!mime) {
throw new DOMException(DOMException.SYNTAX_ERR);
}
mime = String(mime);
if (!parseContentType(mime)) {
throw new DOMException(DOMException.SYNTAX_ERR);
}
this[xhrSymbols.flag].mimeType = mime;
}
send(body) {
if (!this._ownerDocument) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
if (this.readyState !== XMLHttpRequest.OPENED || properties.send) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
properties.beforeSend = true;
try {
if (!flag.body &&
body !== undefined &&
body !== null &&
body !== "" &&
!(flag.method === "HEAD" || flag.method === "GET")) {
let contentType = null;
let encoding = null;
if (body instanceof FormData) {
flag.formData = true;
const formData = [];
for (const entry of idlUtils.implForWrapper(body)._entries) {
let val;
if (Blob.isImpl(entry.value)) {
const blob = entry.value;
val = {
name: entry.name,
value: blob._buffer,
options: {
filename: blob.name,
contentType: blob.type,
knownLength: blob.size
}
};
} else {
val = entry;
}
formData.push(val);
}
flag.body = formData;
// TODO content type; what is the form boundary?
} else if (Blob.is(body)) {
const blob = idlUtils.implForWrapper(body);
flag.body = blob._buffer;
if (blob.type !== "") {
contentType = blob.type;
}
} else if (body instanceof ArrayBuffer) {
flag.body = new Buffer(new Uint8Array(body));
} else if (body instanceof Document.interface) {
if (body.childNodes.length === 0) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
flag.body = domToHtml([body]);
encoding = "UTF-8";
const documentBodyParsingMode = idlUtils.implForWrapper(body)._parsingMode;
contentType = documentBodyParsingMode === "html" ? "text/html" : "application/xml";
contentType += ";charset=UTF-8";
} else if (typeof body !== "string") {
flag.body = String(body);
} else {
flag.body = body;
contentType = "text/plain;charset=UTF-8";
encoding = "UTF-8";
}
const existingContentType = xhrUtils.getRequestHeader(flag.requestHeaders, "content-type");
if (contentType !== null && existingContentType === null) {
flag.requestHeaders["Content-Type"] = contentType;
} else if (existingContentType !== null && encoding !== null) {
const parsed = parseContentType(existingContentType);
if (parsed) {
parsed.parameterList
.filter(v => v.key && v.key.toLowerCase() === "charset" &&
whatwgEncoding.labelToName(v.value) !== "UTF-8")
.forEach(v => {
v.value = "UTF-8";
});
xhrUtils.updateRequestHeader(flag.requestHeaders, "content-type", parsed.toString());
}
}
}
} finally {
if (properties.beforeSend) {
properties.beforeSend = false;
} else {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
}
if (flag.synchronous) {
const flagStr = JSON.stringify(flag, function (k, v) {
if (this === flag && k === "requestManager") {
return null;
}
if (this === flag && k === "pool" && v) {
return { maxSockets: v.maxSockets };
}
return v;
});
const res = spawnSync(
process.execPath,
[syncWorkerFile],
{ input: flagStr }
);
if (res.status !== 0) {
throw new Error(res.stderr.toString());
}
if (res.error) {
if (typeof res.error === "string") {
res.error = new Error(res.error);
}
throw res.error;
}
const response = JSON.parse(res.stdout.toString(), (k, v) => {
if (k === "responseBuffer" && v && v.data) {
return new Buffer(v.data);
}
if (k === "cookieJar" && v) {
return tough.CookieJar.deserializeSync(v, this._ownerDocument._cookieJar.store);
}
return v;
});
response.properties.readyState = XMLHttpRequest.LOADING;
this[xhrSymbols.properties] = response.properties;
if (response.properties.error) {
dispatchError(this);
throw new DOMException(DOMException.NETWORK_ERR, response.properties.error);
} else {
const responseBuffer = this[xhrSymbols.properties].responseBuffer;
const contentLength = getResponseHeader(this, "content-length") || "0";
const bufferLength = parseInt(contentLength) || responseBuffer.length;
const progressObj = { lengthComputable: false };
if (bufferLength !== 0) {
progressObj.total = bufferLength;
progressObj.loaded = bufferLength;
progressObj.lengthComputable = true;
}
this.dispatchEvent(new ProgressEvent("progress", progressObj));
readyStateChange(this, XMLHttpRequest.DONE);
this.dispatchEvent(new ProgressEvent("load", progressObj));
this.dispatchEvent(new ProgressEvent("loadend", progressObj));
}
} else {
properties.send = true;
this.dispatchEvent(new ProgressEvent("loadstart"));
const client = xhrUtils.createClient(this);
properties.client = client;
properties.origin = flag.origin;
client.on("error", err => {
client.removeAllListeners();
properties.error = err;
dispatchError(this);
});
client.on("response", res => receiveResponse(this, res));
client.on("redirect", () => {
if (flag.preflight) {
properties.error = "Redirect after preflight forbidden";
dispatchError(this);
client.abort();
return;
}
const response = client.response;
const destUrlObj = new URL(response.request.headers.Referer);
const urlObj = new URL(response.request.uri.href);
if (destUrlObj.origin !== urlObj.origin && destUrlObj.origin !== flag.origin) {
properties.origin = "null";
}
response.request.headers.Origin = properties.origin;
if (flag.origin !== destUrlObj.origin &&
destUrlObj.protocol !== "data:") {
if (!validCORSHeaders(this, response, flag, properties, flag.origin)) {
return;
}
if (urlObj.username || urlObj.password || response.request.uri.href.match(/^https?:\/\/:@/)) {
properties.error = "Userinfo forbidden in cors redirect";
dispatchError(this);
return;
}
}
});
if (body !== undefined &&
body !== null &&
body !== "" &&
!(flag.method === "HEAD" || flag.method === "GET")) {
properties.uploadComplete = false;
setDispatchProgressEvents(this);
} else {
properties.uploadComplete = true;
}
if (this.timeout > 0) {
properties.timeoutStart = (new Date()).getTime();
properties.timeoutFn = () => {
client.abort();
if (!(this.readyState === XMLHttpRequest.UNSENT ||
(this.readyState === XMLHttpRequest.OPENED && !properties.send) ||
this.readyState === XMLHttpRequest.DONE)) {
properties.send = false;
let stateChanged = false;
if (!(flag.method === "HEAD" || flag.method === "GET")) {
this.upload.dispatchEvent(new ProgressEvent("progress"));
readyStateChange(this, XMLHttpRequest.DONE);
this.upload.dispatchEvent(new ProgressEvent("timeout"));
this.upload.dispatchEvent(new ProgressEvent("loadend"));
stateChanged = true;
}
this.dispatchEvent(new ProgressEvent("progress"));
if (!stateChanged) {
readyStateChange(this, XMLHttpRequest.DONE);
}
this.dispatchEvent(new ProgressEvent("timeout"));
this.dispatchEvent(new ProgressEvent("loadend"));
}
properties.readyState = XMLHttpRequest.UNSENT;
};
properties.timeoutId = setTimeout(properties.timeoutFn, this.timeout);
}
}
flag.body = undefined;
flag.formData = false;
}
setRequestHeader(header, value) {
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
if (arguments.length !== 2) {
throw new TypeError("2 arguments required for setRequestHeader");
}
header = toByteString(header);
value = toByteString(value);
if (this.readyState !== XMLHttpRequest.OPENED || properties.send) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
value = normalizeHeaderValue(value);
if (!tokenRegexp.test(header) || !fieldValueRegexp.test(value)) {
throw new DOMException(DOMException.SYNTAX_ERR);
}
const lcHeader = header.toLowerCase();
if (forbiddenRequestHeaders.has(lcHeader) || lcHeader.startsWith("sec-") || lcHeader.startsWith("proxy-")) {
return;
}
const keys = Object.keys(flag.requestHeaders);
let n = keys.length;
while (n--) {
const key = keys[n];
if (key.toLowerCase() === lcHeader) {
flag.requestHeaders[key] += "," + value;
return;
}
}
flag.requestHeaders[lcHeader] = value;
}
toString() {
return "[object XMLHttpRequest]";
}
get _ownerDocument() {
return idlUtils.implForWrapper(window.document);
}
}
addConstants(XMLHttpRequest, {
UNSENT: 0,
OPENED: 1,
HEADERS_RECEIVED: 2,
LOADING: 3,
DONE: 4
});
function readyStateChange(xhr, readyState) {
const properties = xhr[xhrSymbols.properties];
if (properties.readyState === readyState) {
return;
}
properties.readyState = readyState;
const readyStateChangeEvent = new Event("readystatechange");
xhr.dispatchEvent(readyStateChangeEvent);
}
function receiveResponse(xhr, response) {
const properties = xhr[xhrSymbols.properties];
const flag = xhr[xhrSymbols.flag];
const statusCode = response.statusCode;
if (flag.preflight && redirectStatuses.has(statusCode)) {
properties.error = "Redirect after preflight forbidden";
dispatchError(this);
return;
}
let byteOffset = 0;
const headers = {};
const filteredResponseHeaders = [];
const headerMap = {};
const rawHeaders = response.rawHeaders;
const n = Number(rawHeaders.length);
for (let i = 0; i < n; i += 2) {
const k = rawHeaders[i];
const kl = k.toLowerCase();
const v = rawHeaders[i + 1];
if (uniqueResponseHeaders.has(kl)) {
if (headerMap[kl] !== undefined) {
delete headers[headerMap[kl]];
}
headers[k] = v;
} else if (headerMap[kl] !== undefined) {
headers[headerMap[kl]] += ", " + v;
} else {
headers[k] = v;
}
headerMap[kl] = k;
}
const destUrlObj = new URL(response.request.uri.href);
if (properties.origin !== destUrlObj.origin &&
destUrlObj.protocol !== "data:") {
if (!validCORSHeaders(xhr, response, flag, properties, properties.origin)) {
return;
}
const acehStr = response.headers["access-control-expose-headers"];
const aceh = new Set(acehStr ? acehStr.trim().toLowerCase().split(headerListSeparatorRegexp) : []);
for (const header in headers) {
const lcHeader = header.toLowerCase();
if (!corsSafeResponseHeaders.has(lcHeader) && !aceh.has(lcHeader)) {
filteredResponseHeaders.push(header);
}
}
}
for (const header in headers) {
const lcHeader = header.toLowerCase();
if (forbiddenResponseHeaders.has(lcHeader)) {
filteredResponseHeaders.push(header);
}
}
properties.responseURL = destUrlObj.href;
properties.status = statusCode;
properties.statusText = response.statusMessage || HTTP_STATUS_CODES[statusCode] || "";
properties.responseHeaders = headers;
properties.filteredResponseHeaders = filteredResponseHeaders;
const contentLength = getResponseHeader(xhr, "content-length") || "0";
const bufferLength = parseInt(contentLength) || 0;
const progressObj = { lengthComputable: false };
let lastProgressReported;
if (bufferLength !== 0) {
progressObj.total = bufferLength;
progressObj.loaded = 0;
progressObj.lengthComputable = true;
}
properties.responseBuffer = new Buffer(0);
properties.responseCache = null;
properties.responseTextCache = null;
properties.responseXMLCache = null;
readyStateChange(xhr, XMLHttpRequest.HEADERS_RECEIVED);
// Can't use the client since the client gets the post-ungzipping bytes (which can be greater than the
// Content-Length).
response.on("data", chunk => {
byteOffset += chunk.length;
progressObj.loaded = byteOffset;
});
properties.client.on("data", chunk => {
properties.responseBuffer = Buffer.concat([properties.responseBuffer, chunk]);
properties.responseCache = null;
properties.responseTextCache = null;
properties.responseXMLCache = null;
if (properties.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
properties.readyState = XMLHttpRequest.LOADING;
}
xhr.dispatchEvent(new Event("readystatechange"));
if (progressObj.total !== progressObj.loaded || properties.responseBuffer.length === byteOffset) {
if (lastProgressReported !== progressObj.loaded) {
// This is a necessary check in the gzip case where we can be getting new data from the client, as it
// un-gzips, but no new data has been gotten from the response, so we should not fire a progress event.
lastProgressReported = progressObj.loaded;
xhr.dispatchEvent(new ProgressEvent("progress", progressObj));
}
}
});
properties.client.on("end", () => {
clearTimeout(properties.timeoutId);
properties.timeoutFn = null;
properties.timeoutStart = 0;
properties.client = null;
xhr.dispatchEvent(new ProgressEvent("progress", progressObj));
readyStateChange(xhr, XMLHttpRequest.DONE);
xhr.dispatchEvent(new ProgressEvent("load", progressObj));
xhr.dispatchEvent(new ProgressEvent("loadend", progressObj));
});
}
function setDispatchProgressEvents(xhr) {
const properties = xhr[xhrSymbols.properties];
const client = properties.client;
const upload = xhr.upload;
let total = 0;
let lengthComputable = false;
const length = client.headers && parseInt(xhrUtils.getRequestHeader(client.headers, "content-length"));
if (length) {
total = length;
lengthComputable = true;
}
const initProgress = {
lengthComputable,
total,
loaded: 0
};
upload.dispatchEvent(new ProgressEvent("loadstart", initProgress));
client.on("request", req => {
req.on("response", () => {
properties.uploadComplete = true;
const progress = {
lengthComputable,
total,
loaded: total
};
upload.dispatchEvent(new ProgressEvent("progress", progress));
upload.dispatchEvent(new ProgressEvent("load", progress));
upload.dispatchEvent(new ProgressEvent("loadend", progress));
});
});
}
function dispatchError(xhr) {
const properties = xhr[xhrSymbols.properties];
readyStateChange(xhr, XMLHttpRequest.DONE);
if (!properties.uploadComplete) {
xhr.upload.dispatchEvent(new ProgressEvent("error"));
xhr.upload.dispatchEvent(new ProgressEvent("loadend"));
}
xhr.dispatchEvent(new ProgressEvent("error"));
xhr.dispatchEvent(new ProgressEvent("loadend"));
if (xhr._ownerDocument) {
const error = new Error(properties.error);
error.type = "XMLHttpRequest";
xhr._ownerDocument._defaultView._virtualConsole.emit("jsdomError", error);
}
}
function validCORSHeaders(xhr, response, flag, properties, origin) {
const acaoStr = response.headers["access-control-allow-origin"];
const acao = acaoStr ? acaoStr.trim() : null;
if (acao !== "*" && acao !== origin) {
properties.error = "Cross origin " + origin + " forbidden";
dispatchError(xhr);
return false;
}
const acacStr = response.headers["access-control-allow-credentials"];
const acac = acacStr ? acacStr.trim() : null;
if (flag.withCredentials && acac !== "true") {
properties.error = "Credentials forbidden";
dispatchError(xhr);
return false;
}
const acahStr = response.headers["access-control-allow-headers"];
const acah = new Set(acahStr ? acahStr.trim().toLowerCase().split(headerListSeparatorRegexp) : []);
const forbiddenHeaders = Object.keys(flag.requestHeaders).filter(header => {
const lcHeader = header.toLowerCase();
return !simpleHeaders.has(lcHeader) && !acah.has(lcHeader);
});
if (forbiddenHeaders.length > 0) {
properties.error = "Headers " + forbiddenHeaders + " forbidden";
dispatchError(xhr);
return false;
}
return true;
}
function toByteString(value) {
value = String(value);
if (!/^[\0-\xFF]*$/.test(value)) {
throw new TypeError("invalid ByteString");
}
return value;
}
function getContentType(xhr) {
const flag = xhr[xhrSymbols.flag];
return parseContentType(flag.mimeType || getResponseHeader(xhr, "content-type"));
}
function getResponseHeader(xhr, lcHeader) {
const properties = xhr[xhrSymbols.properties];
const keys = Object.keys(properties.responseHeaders);
let n = keys.length;
while (n--) {
const key = keys[n];
if (key.toLowerCase() === lcHeader) {
return properties.responseHeaders[key];
}
}
return null;
}
function normalizeHeaderValue(value) {
return value.replace(/^[\x09\x0A\x0D\x20]+/, "").replace(/[\x09\x0A\x0D\x20]+$/, "");
}
return XMLHttpRequest;
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| Attr-impl.js | 10.34% | (3 / 29) | 0% | (0 / 12) | 0% | (0 / 15) | 10.34% | (3 / 29) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | 1 1 1 | "use strict";
exports.implementation = class AttrImpl {
constructor(_, privateData) {
this._namespace = privateData.namespace !== undefined ? privateData.namespace : null;
this._namespacePrefix = privateData.namespacePrefix !== undefined ? privateData.namespacePrefix : null;
this._localName = privateData.localName;
this._value = privateData.value !== undefined ? privateData.value : "";
this._element = privateData.element !== undefined ? privateData.element : null;
this.specified = true;
}
get namespaceURI() {
return this._namespace;
}
get prefix() {
return this._namespacePrefix;
}
get localName() {
return this._localName;
}
get name() {
return exports.getAttrImplQualifiedName(this);
}
// Delegate to name
get nodeName() {
return this.name;
}
get value() {
return this._value;
}
set value(v) {
if (this._element === null) {
this._value = v;
} else {
exports.changeAttributeImpl(this._element, this, v);
}
}
// Delegate to value
get nodeValue() {
return this.value;
}
set nodeValue(v) {
this.value = v;
}
// Delegate to value
get textContent() {
return this.value;
}
set textContent(v) {
this.value = v;
}
get ownerElement() {
return this._element;
}
};
exports.changeAttributeImpl = function (element, attributeImpl, value) {
// https://dom.spec.whatwg.org/#concept-element-attributes-change
// TODO mutation observer stuff
const oldValue = attributeImpl._value;
attributeImpl._value = value;
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed."
element._attrModified(exports.getAttrImplQualifiedName(attributeImpl), value, oldValue);
};
exports.getAttrImplQualifiedName = function (attributeImpl) {
// https://dom.spec.whatwg.org/#concept-attribute-qualified-name
if (attributeImpl._namespacePrefix === null) {
return attributeImpl._localName;
}
return attributeImpl._namespacePrefix + ":" + attributeImpl._localName;
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| DOMParser-impl.js | 23.81% | (5 / 21) | 0% | (0 / 8) | 0% | (0 / 2) | 23.81% | (5 / 21) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 1 1 1 1 1 | "use strict";
const Document = require("../generated/Document");
const core = require("..");
const applyDocumentFeatures = require("../../browser/documentfeatures").applyDocumentFeatures;
exports.implementation = class DOMParserImpl {
parseFromString(string, contentType) {
switch (String(contentType)) {
case "text/html": {
return createScriptingDisabledDocument("html", contentType, string);
}
case "text/xml":
case "application/xml":
case "application/xhtml+xml":
case "image/svg+xml": {
// TODO: use a strict XML parser (sax's strict mode might work?) and create parsererror elements
try {
return createScriptingDisabledDocument("xml", contentType, string);
} catch (error) {
const document = createScriptingDisabledDocument("xml", contentType);
const element = document.createElementNS(
"http://www.mozilla.org/newlayout/xml/parsererror.xml", "parsererror");
element.textContent = error.message;
document.appendChild(element);
return document;
}
}
default:
throw new TypeError("Invalid contentType");
}
}
};
function createScriptingDisabledDocument(parsingMode, contentType, string) {
const document = Document.createImpl([], {
core,
options: {
parsingMode,
encoding: "UTF-8",
contentType
// TODO: somehow set URL to active document's URL
}
});
// "scripting enabled" set to false
applyDocumentFeatures(document, {
FetchExternalResources: [],
ProcessExternalResources: false,
SkipExternalResources: false
});
if (string !== undefined) {
document._htmlToDom.appendHtmlToDocument(string, document);
}
document.close();
return document;
}
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| CustomEvent-impl.js | 33.33% | (2 / 6) | 0% | (0 / 2) | 0% | (0 / 1) | 33.33% | (2 / 6) | |
| ErrorEvent-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| Event-impl.js | 5% | (2 / 40) | 0% | (0 / 12) | 0% | (0 / 9) | 5% | (2 / 40) | |
| EventTarget-impl.js | 7.64% | (12 / 157) | 0% | (0 / 129) | 0% | (0 / 10) | 7.69% | (12 / 156) | |
| FocusEvent-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HashChangeEvent-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| KeyboardEvent-impl.js | 22.22% | (2 / 9) | 0% | (0 / 2) | 0% | (0 / 1) | 22.22% | (2 / 9) | |
| MessageEvent-impl.js | 20% | (2 / 10) | 0% | (0 / 2) | 0% | (0 / 1) | 20% | (2 / 10) | |
| MouseEvent-impl.js | 13.33% | (2 / 15) | 0% | (0 / 2) | 0% | (0 / 1) | 13.33% | (2 / 15) | |
| PopStateEvent-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| ProgressEvent-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| TouchEvent-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| UIEvent-impl.js | 28.57% | (2 / 7) | 0% | (0 / 2) | 0% | (0 / 1) | 28.57% | (2 / 7) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1 1 | "use strict";
const EventImpl = require("./Event-impl").implementation;
class CustomEventImpl extends EventImpl {
initCustomEvent(type, bubbles, cancelable, detail) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.detail = detail;
}
}
module.exports = {
implementation: CustomEventImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 1 | "use strict";
const EventImpl = require("./Event-impl").implementation;
class ErrorEventImpl extends EventImpl {
}
module.exports = {
implementation: ErrorEventImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | 1 1 | "use strict";
const EventInit = require("../generated/EventInit");
class EventImpl {
constructor(args, privateData) {
const type = args[0]; // TODO: Replace with destructuring
const eventInitDict = args[1] || EventInit.convert(undefined);
this.type = type;
const wrapper = privateData.wrapper;
for (const key in eventInitDict) {
if (key in wrapper) {
this[key] = eventInitDict[key];
}
}
this.target = null;
this.currentTarget = null;
this.eventPhase = 0;
this._initializedFlag = true;
this._stopPropagationFlag = false;
this._stopImmediatePropagationFlag = false;
this._canceledFlag = false;
this._dispatchFlag = false;
this.isTrusted = privateData.isTrusted || false;
this.timeStamp = Date.now();
}
get defaultPrevented() {
return this._canceledFlag;
}
stopPropagation() {
this._stopPropagationFlag = true;
}
get cancelBubble() {
return this._stopPropagationFlag;
}
set cancelBubble(v) {
if (v) {
this._stopPropagationFlag = true;
}
}
stopImmediatePropagation() {
this._stopPropagationFlag = true;
this._stopImmediatePropagationFlag = true;
}
preventDefault() {
if (this.cancelable) {
this._canceledFlag = true;
}
}
_initialize(type, bubbles, cancelable) {
this.type = type;
this._initializedFlag = true;
this._stopPropagationFlag = false;
this._stopImmediatePropagationFlag = false;
this._canceledFlag = false;
this.isTrusted = false;
this.target = null;
this.bubbles = bubbles;
this.cancelable = cancelable;
}
initEvent(type, bubbles, cancelable) {
if (this._dispatchFlag) {
return;
}
this._initialize(type, bubbles, cancelable);
}
}
module.exports = {
implementation: EventImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const DOMException = require("../../web-idl/DOMException");
const reportException = require("../helpers/runtime-script-errors");
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const idlUtils = require("../generated/utils");
const EventImpl = require("./Event-impl").implementation;
const Event = require("../generated/Event").interface;
class EventTargetImpl {
constructor() {
this._eventListeners = Object.create(null);
}
addEventListener(type, callback, options) {
// webidl2js currently can't handle neither optional arguments nor callback interfaces
if (callback === undefined || callback === null) {
callback = null;
} else if (typeof callback !== "object" && typeof callback !== "function") {
throw new TypeError("Only undefined, null, an object, or a function are allowed for the callback parameter");
}
options = normalizeEventHandlerOptions(options, ["capture", "once"]);
if (callback === null) {
return;
}
if (!this._eventListeners[type]) {
this._eventListeners[type] = [];
}
for (let i = 0; i < this._eventListeners[type].length; ++i) {
const listener = this._eventListeners[type][i];
if (listener.options.capture === options.capture && listener.callback === callback) {
return;
}
}
this._eventListeners[type].push({
callback,
options
});
}
removeEventListener(type, callback, options) {
if (callback === undefined || callback === null) {
callback = null;
} else if (typeof callback !== "object" && typeof callback !== "function") {
throw new TypeError("Only undefined, null, an object, or a function are allowed for the callback parameter");
}
options = normalizeEventHandlerOptions(options, ["capture"]);
if (callback === null) {
// Optimization, not in the spec.
return;
}
if (!this._eventListeners[type]) {
return;
}
for (let i = 0; i < this._eventListeners[type].length; ++i) {
const listener = this._eventListeners[type][i];
if (listener.callback === callback && listener.options.capture === options.capture) {
this._eventListeners[type].splice(i, 1);
break;
}
}
}
dispatchEvent(eventImpl) {
if (!(eventImpl instanceof EventImpl)) {
throw new TypeError("Argument to dispatchEvent must be an Event");
}
if (eventImpl._dispatchFlag || !eventImpl._initializedFlag) {
throw new DOMException(DOMException.INVALID_STATE_ERR, "Tried to dispatch an uninitialized event");
}
if (eventImpl.eventPhase !== Event.NONE) {
throw new DOMException(DOMException.INVALID_STATE_ERR, "Tried to dispatch a dispatching event");
}
eventImpl.isTrusted = false;
return this._dispatch(eventImpl);
}
_dispatch(eventImpl, targetOverride) {
eventImpl._dispatchFlag = true;
eventImpl.target = targetOverride || this;
const eventPath = [];
let targetParent = domSymbolTree.parent(eventImpl.target);
let target = eventImpl.target;
while (targetParent) {
eventPath.push(targetParent);
target = targetParent;
targetParent = domSymbolTree.parent(targetParent);
}
if (eventImpl.type !== "load" && target._defaultView) {
// https://html.spec.whatwg.org/#events-and-the-window-object
eventPath.push(idlUtils.implForWrapper(target._defaultView));
}
eventImpl.eventPhase = Event.CAPTURING_PHASE;
for (let i = eventPath.length - 1; i >= 0; --i) {
if (eventImpl._stopPropagationFlag) {
break;
}
const object = eventPath[i];
const objectImpl = idlUtils.implForWrapper(object) || object; // window :(
const eventListeners = objectImpl._eventListeners[eventImpl.type];
invokeEventListeners(eventListeners, object, eventImpl);
}
eventImpl.eventPhase = Event.AT_TARGET;
if (!eventImpl._stopPropagationFlag) {
invokeInlineListeners(eventImpl.target, eventImpl);
if (this._eventListeners[eventImpl.type]) {
const eventListeners = this._eventListeners[eventImpl.type];
invokeEventListeners(eventListeners, eventImpl.target, eventImpl);
}
}
if (eventImpl.bubbles) {
eventImpl.eventPhase = Event.BUBBLING_PHASE;
for (let i = 0; i < eventPath.length; ++i) {
if (eventImpl._stopPropagationFlag) {
break;
}
const object = eventPath[i];
const objectImpl = idlUtils.implForWrapper(object) || object; // window :(
const eventListeners = objectImpl._eventListeners[eventImpl.type];
invokeInlineListeners(object, eventImpl);
invokeEventListeners(eventListeners, object, eventImpl);
}
}
eventImpl._dispatchFlag = false;
eventImpl._stopPropagationFlag = false;
eventImpl._stopImmediatePropagationFlag = false;
eventImpl.eventPhase = Event.NONE;
eventImpl.currentTarget = null;
return !eventImpl._canceledFlag;
}
}
module.exports = {
implementation: EventTargetImpl
};
function invokeInlineListeners(object, event) {
const wrapper = idlUtils.wrapperForImpl(object);
const inlineListener = getListenerForInlineEventHandler(wrapper, event.type);
if (inlineListener) {
const document = object._ownerDocument || (wrapper && (wrapper._document || wrapper._ownerDocument));
// Will be falsy for windows that have closed
if (document && (!object.nodeName || document.implementation._hasFeature("ProcessExternalResources", "script"))) {
invokeEventListeners([{
callback: inlineListener,
options: normalizeEventHandlerOptions(false, ["capture", "once"])
}], object, event);
}
}
}
function invokeEventListeners(listeners, target, eventImpl) {
const wrapper = idlUtils.wrapperForImpl(target);
const document = target._ownerDocument || (wrapper && (wrapper._document || wrapper._ownerDocument));
// Will be falsy for windows that have closed
if (!document) {
return;
}
// workaround for events emitted on window (window-proxy)
// the wrapper is the root window instance, but we only want to expose the vm proxy at all times
if (wrapper._document) {
target = idlUtils.implForWrapper(wrapper._document)._defaultView;
}
eventImpl.currentTarget = target;
if (!listeners) {
return;
}
const handlers = listeners.slice();
for (let i = 0; i < handlers.length; ++i) {
if (eventImpl._stopImmediatePropagationFlag) {
return;
}
const listener = handlers[i];
const capture = listener.options.capture;
const once = listener.options.once;
// const passive = listener.options.passive;
if (listeners.indexOf(listener) === -1 ||
(eventImpl.eventPhase === Event.CAPTURING_PHASE && !capture) ||
(eventImpl.eventPhase === Event.BUBBLING_PHASE && capture)) {
continue;
}
if (once) {
listeners.splice(listeners.indexOf(listener), 1);
}
try {
if (typeof listener.callback === "object") {
if (typeof listener.callback.handleEvent === "function") {
listener.callback.handleEvent(idlUtils.wrapperForImpl(eventImpl));
}
} else {
listener.callback.call(idlUtils.wrapperForImpl(eventImpl.currentTarget), idlUtils.wrapperForImpl(eventImpl));
}
} catch (e) {
let window = null;
if (wrapper && wrapper._document) {
// Triggered by Window
window = wrapper;
} else if (target._ownerDocument) {
// Triggered by most webidl2js'ed instances
window = target._ownerDocument._defaultView;
} else if (wrapper._ownerDocument) {
// Currently triggered by XHR and some other non-webidl2js things
window = wrapper._ownerDocument._defaultView;
}
if (window) {
reportException(window, e);
}
// Errors in window-less documents just get swallowed... can you think of anything better?
}
}
}
const wrappedListener = Symbol("inline event listener wrapper");
/**
* Normalize the event listeners options argument in order to get always a valid options object
* @param {Object} options - user defined options
* @param {Array} defaultBoolKeys - boolean properties that should belong to the options object
* @returns {Object} object containing at least the "defaultBoolKeys"
*/
function normalizeEventHandlerOptions(options, defaultBoolKeys) {
const returnValue = {};
// no need to go further here
if (typeof options === "boolean" || options === null || typeof options === "undefined") {
returnValue.capture = Boolean(options);
return returnValue;
}
// non objects options so we typecast its value as "capture" value
if (typeof options !== "object") {
returnValue.capture = Boolean(options);
// at this point we don't need to loop the "capture" key anymore
defaultBoolKeys = defaultBoolKeys.filter(k => k !== "capture");
}
for (const key of defaultBoolKeys) {
returnValue[key] = Boolean(options[key]);
}
return returnValue;
}
function getListenerForInlineEventHandler(target, type) {
const callback = target["on" + type];
if (!callback) { // TODO event handlers: only check null
return null;
}
if (!callback[wrappedListener]) {
// https://html.spec.whatwg.org/multipage/webappapis.html#the-event-handler-processing-algorithm
callback[wrappedListener] = function (E) {
const isWindowError = E.constructor.name === "ErrorEvent" && type === "error"; // TODO branding
let returnValue;
if (isWindowError) {
returnValue = callback.call(E.currentTarget, E.message, E.filename, E.lineno, E.colno, E.error);
} else {
returnValue = callback.call(E.currentTarget, E);
}
if (type === "mouseover" || isWindowError) {
if (returnValue === true) {
E.preventDefault();
}
} else if (returnValue === false) {
E.preventDefault();
}
};
}
return callback[wrappedListener];
}
|
| 1 2 3 4 5 6 | 1 1 | "use strict";
const EventImpl = require("./Event-impl").implementation;
exports.implementation = class FocusEventImpl extends EventImpl { };
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 1 | "use strict";
const EventImpl = require("./Event-impl").implementation;
class HashChangeEventImpl extends EventImpl {
}
module.exports = {
implementation: HashChangeEventImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1 1 | "use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
class KeyboardEventImpl extends UIEventImpl {
initKeyboardEvent(type, bubbles, cancelable, view, key, location, modifiersList, repeat, locale) {
if (this._dispatchFlag) {
return;
}
this.initUIEvent(type, bubbles, cancelable, view, key);
this.location = location;
this.modifiersList = modifiersList;
this.repeat = repeat;
this.locale = locale;
}
}
module.exports = {
implementation: KeyboardEventImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1 1 | "use strict";
const EventImpl = require("./Event-impl").implementation;
class MessageEventImpl extends EventImpl {
initMessageEvent(type, bubbles, cancelable, data, origin, lastEventId, source, ports) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.data = data;
this.origin = origin;
this.lastEventId = lastEventId;
this.source = source;
this.ports = ports;
}
}
module.exports = {
implementation: MessageEventImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 1 1 | "use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
class MouseEventImpl extends UIEventImpl {
initMouseEvent(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY,
ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget) {
if (this._dispatchFlag) {
return;
}
this.initUIEvent(type, bubbles, cancelable, view, detail);
this.screenX = screenX;
this.screenY = screenY;
this.clientX = clientX;
this.clientY = clientY;
this.ctrlKey = ctrlKey;
this.altKey = altKey;
this.shiftKey = shiftKey;
this.metaKey = metaKey;
this.button = button;
this.relatedTarget = relatedTarget;
}
}
module.exports = {
implementation: MouseEventImpl
};
|
| 1 2 3 4 5 6 | 1 1 | "use strict";
const EventImpl = require("./Event-impl.js").implementation;
exports.implementation = class PopStateEventImpl extends EventImpl {};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 1 | "use strict";
const EventImpl = require("./Event-impl").implementation;
class ProgressEventImpl extends EventImpl {
}
module.exports = {
implementation: ProgressEventImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 1 | "use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
class TouchEventImpl extends UIEventImpl {
}
module.exports = {
implementation: TouchEventImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1 1 | "use strict";
const EventImpl = require("./Event-impl").implementation;
class UIEventImpl extends EventImpl {
initUIEvent(type, bubbles, cancelable, view, detail) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.view = view;
this.detail = detail;
}
}
module.exports = {
implementation: UIEventImpl
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| Blob-impl.js | 7.02% | (4 / 57) | 0% | (0 / 32) | 0% | (0 / 4) | 7.02% | (4 / 57) | |
| File-impl.js | 25% | (2 / 8) | 0% | (0 / 2) | 0% | (0 / 1) | 25% | (2 / 8) | |
| FileList-impl.js | 33.33% | (1 / 3) | 0% | (0 / 2) | 0% | (0 / 2) | 33.33% | (1 / 3) | |
| FileReader-impl.js | 12.86% | (9 / 70) | 0% | (0 / 29) | 0% | (0 / 7) | 12.86% | (9 / 70) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 1 1 1 1 | "use strict";
const idlUtils = require("../generated/utils");
const conversions = require("webidl-conversions");
const Blob = require("../generated/Blob");
exports.implementation = class BlobImpl {
constructor(args) {
const parts = args[0];
const properties = args[1];
const buffers = [];
if (parts !== undefined) {
if (parts === null || typeof parts !== "object" || typeof parts[Symbol.iterator] !== "function") {
throw new TypeError("parts must be an iterable object");
}
const arr = [];
for (const part of parts) {
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part) || Blob.is(part)) {
arr.push(idlUtils.tryImplForWrapper(part));
} else {
arr.push(conversions.USVString(part));
}
}
for (const part of arr) {
let buffer;
if (part instanceof ArrayBuffer) {
buffer = new Buffer(new Uint8Array(part));
} else if (ArrayBuffer.isView(part)) {
buffer = new Buffer(new Uint8Array(part.buffer, part.byteOffset, part.byteLength));
} else if (Blob.isImpl(part)) {
buffer = part._buffer;
} else {
buffer = new Buffer(part);
}
buffers.push(buffer);
}
}
this._buffer = Buffer.concat(buffers);
this.type = properties.type;
if (/[^\u0020-\u007E]/.test(this.type)) {
this.type = "";
} else {
this.type = this.type.toLowerCase();
}
this.isClosed = false;
}
get size() {
return this.isClosed ? 0 : this._buffer.length;
}
slice(start, end, contentType) {
const size = this.size;
let relativeStart;
let relativeEnd;
let relativeContentType;
if (start === undefined) {
relativeStart = 0;
} else if (start < 0) {
relativeStart = Math.max(size + start, 0);
} else {
relativeStart = Math.min(start, size);
}
if (end === undefined) {
relativeEnd = size;
} else if (end < 0) {
relativeEnd = Math.max(size + end, 0);
} else {
relativeEnd = Math.min(end, size);
}
if (contentType === undefined) {
relativeContentType = "";
} else {
// sanitization (lower case and invalid char check) is done in the
// constructor
relativeContentType = contentType;
}
const span = Math.max(relativeEnd - relativeStart, 0);
const buffer = this._buffer;
const slicedBuffer = buffer.slice(
relativeStart,
relativeStart + span
);
const blob = Blob.createImpl([[], { type: relativeContentType }], {});
blob.isClosed = this.isClosed;
blob._buffer = slicedBuffer;
return blob;
}
close() {
this.isClosed = true;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 1 1 | "use strict";
const BlobImpl = require("./Blob-impl").implementation;
exports.implementation = class FileImpl extends BlobImpl {
constructor(args, privateData) {
const fileBits = args[0];
const fileName = args[1];
const options = args[2];
super([fileBits, options], privateData);
this.name = fileName.replace(/\//g, ":");
this.lastModified = "lastModified" in options ? options.lastModified : Date.now();
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 | 1 | "use strict";
exports.implementation = class FileListImpl extends Array {
constructor() {
super(0);
}
item(index) {
return this[index] || null;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | 1 1 1 1 1 1 1 1 1 | "use strict";
const whatwgEncoding = require("whatwg-encoding");
const parseContentType = require("content-type-parser");
const querystring = require("querystring");
const DOMException = require("../../web-idl/DOMException");
const EventTargetImpl = require("../events/EventTarget-impl").implementation;
const Blob = require("../generated/Blob");
const ProgressEvent = require("../generated/ProgressEvent");
const READY_STATES = Object.freeze({
EMPTY: 0,
LOADING: 1,
DONE: 2
});
exports.implementation = class FileReaderImpl extends EventTargetImpl {
constructor(args, privateData) {
super([], privateData);
this.error = null;
this.readyState = READY_STATES.EMPTY;
this.result = null;
this.onloadstart = null;
this.onprogress = null;
this.onload = null;
this.onabort = null;
this.onerror = null;
this.onloadend = null;
this._ownerDocument = privateData.window.document;
}
readAsArrayBuffer(file) {
this._readFile(file, "buffer");
}
readAsDataURL(file) {
this._readFile(file, "dataURL");
}
readAsText(file, encoding) {
this._readFile(file, "text", whatwgEncoding.labelToName(encoding) || "UTF-8");
}
abort() {
if (this.readyState === READY_STATES.DONE || this.readyState === READY_STATES.EMPTY) {
this.result = null;
return;
}
if (this.readyState === READY_STATES.LOADING) {
this.readyState = READY_STATES.DONE;
}
this._fireProgressEvent("abort");
this._fireProgressEvent("loadend");
}
_fireProgressEvent(name, props) {
const event = ProgressEvent.createImpl([name, Object.assign({ bubbles: false, cancelable: false }, props)], {});
this.dispatchEvent(event);
}
_readFile(file, format, encoding) {
if (!Blob.isImpl(file)) {
throw new TypeError("file argument must be a Blob");
}
if (this.readyState === READY_STATES.LOADING) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
if (file.isClosed) {
this.error = new DOMException(DOMException.INVALID_STATE_ERR);
this._fireProgressEvent("error");
}
this.readyState = READY_STATES.LOADING;
this._fireProgressEvent("loadstart");
process.nextTick(() => {
let data = file._buffer;
if (!data) {
data = new Buffer("");
}
this._fireProgressEvent("progress", {
lengthComputable: !isNaN(file.size),
total: file.size,
loaded: data.length
});
process.nextTick(() => {
switch (format) {
default:
case "buffer": {
this.result = (new Uint8Array(data)).buffer;
break;
}
case "dataURL": {
let dataUrl = "data:";
const contentType = parseContentType(file.type);
if (contentType && contentType.isText()) {
const fallbackEncoding = whatwgEncoding.getBOMEncoding(data) ||
whatwgEncoding.labelToName(contentType.get("charset")) || "UTF-8";
const decoded = whatwgEncoding.decode(data, fallbackEncoding);
contentType.set("charset", encoding);
dataUrl += contentType.toString();
dataUrl += ",";
dataUrl += querystring.escape(decoded);
} else {
if (contentType) {
dataUrl += contentType.toString();
}
dataUrl += ";base64,";
dataUrl += data.toString("base64");
}
this.result = dataUrl;
break;
}
case "text": {
this.result = whatwgEncoding.decode(data, encoding);
break;
}
}
this.readyState = READY_STATES.DONE;
this._fireProgressEvent("load");
this._fireProgressEvent("loadend");
});
});
}
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| Attr.js | 27.69% | (18 / 65) | 0% | (0 / 16) | 0% | (0 / 21) | 28.13% | (18 / 64) | |
| Blob.js | 20% | (14 / 70) | 0% | (0 / 36) | 0% | (0 / 13) | 20.29% | (14 / 69) | |
| BlobPropertyBag.js | 18.75% | (3 / 16) | 0% | (0 / 14) | 0% | (0 / 2) | 18.75% | (3 / 16) | |
| CDATASection.js | 25.58% | (11 / 43) | 0% | (0 / 16) | 0% | (0 / 8) | 26.19% | (11 / 42) | |
| CharacterData.js | 22.52% | (25 / 111) | 0% | (0 / 56) | 0% | (0 / 16) | 22.73% | (25 / 110) | |
| ChildNode.js | 21.28% | (10 / 47) | 0% | (0 / 22) | 0% | (0 / 9) | 21.74% | (10 / 46) | |
| Comment.js | 22.45% | (11 / 49) | 0% | (0 / 20) | 0% | (0 / 8) | 22.92% | (11 / 48) | |
| CustomEvent.js | 20.59% | (14 / 68) | 0% | (0 / 33) | 0% | (0 / 10) | 20.9% | (14 / 67) | |
| CustomEventInit.js | 22.22% | (4 / 18) | 0% | (0 / 14) | 0% | (0 / 2) | 22.22% | (4 / 18) | |
| DOMImplementation.js | 14.63% | (12 / 82) | 0% | (0 / 54) | 0% | (0 / 12) | 14.81% | (12 / 81) | |
| DOMParser.js | 17.31% | (9 / 52) | 0% | (0 / 26) | 0% | (0 / 9) | 17.65% | (9 / 51) | |
| Document.js | 21.21% | (77 / 363) | 0% | (0 / 210) | 0% | (0 / 71) | 21.27% | (77 / 362) | |
| DocumentFragment.js | 30% | (15 / 50) | 0% | (0 / 18) | 0% | (0 / 8) | 30.61% | (15 / 49) | |
| DocumentType.js | 33.96% | (18 / 53) | 0% | (0 / 16) | 0% | (0 / 11) | 34.62% | (18 / 52) | |
| Element.js | 18.24% | (62 / 340) | 0% | (0 / 220) | 0% | (0 / 56) | 18.29% | (62 / 339) | |
| ElementCSSInlineStyle.js | 21.43% | (9 / 42) | 0% | (0 / 16) | 0% | (0 / 10) | 21.95% | (9 / 41) | |
| ElementContentEditable.js | 20.51% | (8 / 39) | 0% | (0 / 16) | 0% | (0 / 8) | 21.05% | (8 / 38) | |
| ErrorEvent.js | 26.98% | (17 / 63) | 0% | (0 / 25) | 0% | (0 / 13) | 27.42% | (17 / 62) | |
| ErrorEventInit.js | 12.12% | (4 / 33) | 0% | (0 / 38) | 0% | (0 / 2) | 12.12% | (4 / 33) | |
| Event.js | 26.79% | (30 / 112) | 0% | (0 / 51) | 0% | (0 / 23) | 27.03% | (30 / 111) | |
| EventInit.js | 14.29% | (3 / 21) | 0% | (0 / 20) | 0% | (0 / 2) | 14.29% | (3 / 21) | |
| EventModifierInit.js | 4.55% | (4 / 88) | 0% | (0 / 98) | 0% | (0 / 2) | 4.55% | (4 / 88) | |
| EventTarget.js | 15.28% | (11 / 72) | 0% | (0 / 48) | 0% | (0 / 11) | 15.49% | (11 / 71) | |
| File.js | 24.56% | (14 / 57) | 0% | (0 / 25) | 0% | (0 / 10) | 25% | (14 / 56) | |
| FileList.js | 19.61% | (10 / 51) | 0% | (0 / 24) | 0% | (0 / 10) | 20% | (10 / 50) | |
| FilePropertyBag.js | 23.53% | (4 / 17) | 0% | (0 / 14) | 0% | (0 / 2) | 23.53% | (4 / 17) | |
| FileReader.js | 5.98% | (7 / 117) | 0% | (0 / 54) | 0% | (0 / 28) | 6.03% | (7 / 116) | |
| FocusEvent.js | 23.64% | (13 / 55) | 0% | (0 / 25) | 0% | (0 / 9) | 24.07% | (13 / 54) | |
| FocusEventInit.js | 22.22% | (4 / 18) | 0% | (0 / 14) | 0% | (0 / 2) | 22.22% | (4 / 18) | |
| FormData.js | 13.21% | (14 / 106) | 0% | (0 / 70) | 0% | (0 / 14) | 13.33% | (14 / 105) | |
| GlobalEventHandlers.js | 31.14% | (71 / 228) | 0% | (0 / 16) | 0% | (0 / 134) | 31.28% | (71 / 227) | |
| HTMLAnchorElement.js | 25.74% | (26 / 101) | 0% | (0 / 36) | 0% | (0 / 30) | 26% | (26 / 100) | |
| HTMLAppletElement.js | 22.45% | (22 / 98) | 0% | (0 / 44) | 0% | (0 / 30) | 22.68% | (22 / 97) | |
| HTMLAreaElement.js | 26.92% | (21 / 78) | 0% | (0 / 28) | 0% | (0 / 20) | 27.27% | (21 / 77) | |
| HTMLAudioElement.js | 25.58% | (11 / 43) | 0% | (0 / 16) | 0% | (0 / 8) | 26.19% | (11 / 42) | |
| HTMLBRElement.js | 25% | (12 / 48) | 0% | (0 / 18) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLBaseElement.js | 25% | (13 / 52) | 0% | (0 / 18) | 0% | (0 / 12) | 25.49% | (13 / 51) | |
| HTMLBodyElement.js | 27.27% | (21 / 77) | 0% | (0 / 28) | 0% | (0 / 20) | 27.63% | (21 / 76) | |
| HTMLButtonElement.js | 23.17% | (19 / 82) | 0% | (0 / 28) | 0% | (0 / 23) | 23.46% | (19 / 81) | |
| HTMLCanvasElement.js | 16.67% | (18 / 108) | 0% | (0 / 58) | 0% | (0 / 17) | 16.82% | (18 / 107) | |
| HTMLDListElement.js | 24.49% | (12 / 49) | 0% | (0 / 18) | 0% | (0 / 10) | 25% | (12 / 48) | |
| HTMLDataElement.js | 25% | (12 / 48) | 0% | (0 / 18) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLDataListElement.js | 25.58% | (11 / 43) | 0% | (0 / 16) | 0% | (0 / 8) | 26.19% | (11 / 42) | |
| HTMLDialogElement.js | 24.49% | (12 / 49) | 0% | (0 / 18) | 0% | (0 / 10) | 25% | (12 / 48) | |
| HTMLDirectoryElement.js | 24.49% | (12 / 49) | 0% | (0 / 18) | 0% | (0 / 10) | 25% | (12 / 48) | |
| HTMLDivElement.js | 25% | (12 / 48) | 0% | (0 / 18) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLElement.js | 30.7% | (35 / 114) | 0% | (0 / 44) | 0% | (0 / 28) | 30.97% | (35 / 113) | |
| HTMLEmbedElement.js | 23.61% | (17 / 72) | 0% | (0 / 26) | 0% | (0 / 20) | 23.94% | (17 / 71) | |
| HTMLFieldSetElement.js | 25% | (14 / 56) | 0% | (0 / 20) | 0% | (0 / 13) | 25.45% | (14 / 55) | |
| HTMLFontElement.js | 24.14% | (14 / 58) | 0% | (0 / 22) | 0% | (0 / 14) | 24.56% | (14 / 57) | |
| HTMLFormElement.js | 23.4% | (22 / 94) | 0% | (0 / 36) | 0% | (0 / 26) | 23.66% | (22 / 93) | |
| HTMLFrameElement.js | 24.42% | (21 / 86) | 0% | (0 / 28) | 0% | (0 / 26) | 24.71% | (21 / 85) | |
| HTMLFrameSetElement.js | 29.82% | (17 / 57) | 0% | (0 / 20) | 0% | (0 / 12) | 30.36% | (17 / 56) | |
| HTMLHRElement.js | 23.19% | (16 / 69) | 0% | (0 / 26) | 0% | (0 / 18) | 23.53% | (16 / 68) | |
| HTMLHeadElement.js | 25.58% | (11 / 43) | 0% | (0 / 16) | 0% | (0 / 8) | 26.19% | (11 / 42) | |
| HTMLHeadingElement.js | 25% | (12 / 48) | 0% | (0 / 18) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLHtmlElement.js | 25% | (12 / 48) | 0% | (0 / 18) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLHyperlinkElementUtils.js | 23.46% | (19 / 81) | 0% | (0 / 18) | 0% | (0 / 29) | 23.75% | (19 / 80) | |
| HTMLIFrameElement.js | 23.08% | (27 / 117) | 0% | (0 / 42) | 0% | (0 / 37) | 23.28% | (27 / 116) | |
| HTMLImageElement.js | 23.66% | (31 / 131) | 0% | (0 / 52) | 0% | (0 / 44) | 23.85% | (31 / 130) | |
| HTMLInputElement.js | 19.92% | (48 / 241) | 0% | (0 / 98) | 0% | (0 / 77) | 20% | (48 / 240) | |
| HTMLLIElement.js | 24.53% | (13 / 53) | 0% | (0 / 23) | 0% | (0 / 12) | 25% | (13 / 52) | |
| HTMLLabelElement.js | 26% | (13 / 50) | 0% | (0 / 18) | 0% | (0 / 11) | 26.53% | (13 / 49) | |
| HTMLLegendElement.js | 26% | (13 / 50) | 0% | (0 / 18) | 0% | (0 / 11) | 26.53% | (13 / 49) | |
| HTMLLinkElement.js | 25.81% | (24 / 93) | 0% | (0 / 36) | 0% | (0 / 26) | 26.09% | (24 / 92) | |
| HTMLMapElement.js | 26% | (13 / 50) | 0% | (0 / 18) | 0% | (0 / 11) | 26.53% | (13 / 49) | |
| HTMLMediaElement.js | 30.57% | (59 / 193) | 0% | (0 / 70) | 0% | (0 / 50) | 30.73% | (59 / 192) | |
| HTMLMenuElement.js | 23.73% | (14 / 59) | 0% | (0 / 22) | 0% | (0 / 14) | 24.14% | (14 / 58) | |
| HTMLMetaElement.js | 23.81% | (15 / 63) | 0% | (0 / 24) | 0% | (0 / 16) | 24.19% | (15 / 62) | |
| HTMLMeterElement.js | 25.58% | (11 / 43) | 0% | (0 / 16) | 0% | (0 / 8) | 26.19% | (11 / 42) | |
| HTMLModElement.js | 24.53% | (13 / 53) | 0% | (0 / 20) | 0% | (0 / 12) | 25% | (13 / 52) | |
| HTMLOListElement.js | 23.08% | (15 / 65) | 0% | (0 / 27) | 0% | (0 / 16) | 23.44% | (15 / 64) | |
| HTMLObjectElement.js | 22.66% | (29 / 128) | 0% | (0 / 54) | 0% | (0 / 42) | 22.83% | (29 / 127) | |
| HTMLOptGroupElement.js | 24.07% | (13 / 54) | 0% | (0 / 20) | 0% | (0 / 12) | 24.53% | (13 / 53) | |
| HTMLOptionElement.js | 25.33% | (19 / 75) | 0% | (0 / 20) | 0% | (0 / 22) | 25.68% | (19 / 74) | |
| HTMLOutputElement.js | 25% | (12 / 48) | 0% | (0 / 18) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLParagraphElement.js | 25% | (12 / 48) | 0% | (0 / 18) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLParamElement.js | 23.81% | (15 / 63) | 0% | (0 / 24) | 0% | (0 / 16) | 24.19% | (15 / 62) | |
| HTMLPreElement.js | 25% | (12 / 48) | 0% | (0 / 21) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLProgressElement.js | 25.58% | (11 / 43) | 0% | (0 / 16) | 0% | (0 / 8) | 26.19% | (11 / 42) | |
| HTMLQuoteElement.js | 25% | (12 / 48) | 0% | (0 / 18) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLScriptElement.js | 22.47% | (20 / 89) | 0% | (0 / 34) | 0% | (0 / 26) | 22.73% | (20 / 88) | |
| HTMLSelectElement.js | 22.32% | (25 / 112) | 0% | (0 / 44) | 0% | (0 / 31) | 22.52% | (25 / 111) | |
| HTMLSourceElement.js | 23.88% | (16 / 67) | 0% | (0 / 24) | 0% | (0 / 18) | 24.24% | (16 / 66) | |
| HTMLSpanElement.js | 25.58% | (11 / 43) | 0% | (0 / 16) | 0% | (0 / 8) | 26.19% | (11 / 42) | |
| HTMLStyleElement.js | 29.03% | (18 / 62) | 0% | (0 / 22) | 0% | (0 / 14) | 29.51% | (18 / 61) | |
| HTMLTableCaptionElement.js | 25% | (12 / 48) | 0% | (0 / 18) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLTableCellElement.js | 23.53% | (24 / 102) | 0% | (0 / 34) | 0% | (0 / 33) | 23.76% | (24 / 101) | |
| HTMLTableColElement.js | 22.97% | (17 / 74) | 0% | (0 / 33) | 0% | (0 / 20) | 23.29% | (17 / 73) | |
| HTMLTableDataCellElement.js | 25% | (12 / 48) | 0% | (0 / 18) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLTableElement.js | 19.53% | (33 / 169) | 0% | (0 / 98) | 0% | (0 / 42) | 19.64% | (33 / 168) | |
| HTMLTableHeaderCellElement.js | 24.14% | (14 / 58) | 0% | (0 / 22) | 0% | (0 / 14) | 24.56% | (14 / 57) | |
| HTMLTableRowElement.js | 22.34% | (21 / 94) | 0% | (0 / 42) | 0% | (0 / 23) | 22.58% | (21 / 93) | |
| HTMLTableSectionElement.js | 21.18% | (18 / 85) | 0% | (0 / 40) | 0% | (0 / 19) | 21.43% | (18 / 84) | |
| HTMLTemplateElement.js | 26.67% | (12 / 45) | 0% | (0 / 16) | 0% | (0 / 9) | 27.27% | (12 / 44) | |
| HTMLTextAreaElement.js | 20.34% | (36 / 177) | 0% | (0 / 82) | 0% | (0 / 52) | 20.45% | (36 / 176) | |
| HTMLTimeElement.js | 25% | (12 / 48) | 0% | (0 / 18) | 0% | (0 / 10) | 25.53% | (12 / 47) | |
| HTMLTitleElement.js | 25.53% | (12 / 47) | 0% | (0 / 16) | 0% | (0 / 10) | 26.09% | (12 / 46) | |
| HTMLTrackElement.js | 32.05% | (25 / 78) | 0% | (0 / 24) | 0% | (0 / 19) | 32.47% | (25 / 77) | |
| HTMLUListElement.js | 24.07% | (13 / 54) | 0% | (0 / 20) | 0% | (0 / 12) | 24.53% | (13 / 53) | |
| HTMLUnknownElement.js | 25.58% | (11 / 43) | 0% | (0 / 16) | 0% | (0 / 8) | 26.19% | (11 / 42) | |
| HTMLVideoElement.js | 25.4% | (16 / 63) | 0% | (0 / 30) | 0% | (0 / 16) | 25.81% | (16 / 62) | |
| HashChangeEvent.js | 24.56% | (14 / 57) | 0% | (0 / 25) | 0% | (0 / 10) | 25% | (14 / 56) | |
| HashChangeEventInit.js | 19.05% | (4 / 21) | 0% | (0 / 20) | 0% | (0 / 2) | 19.05% | (4 / 21) | |
| History.js | 15.15% | (15 / 99) | 0% | (0 / 64) | 0% | (0 / 15) | 15.31% | (15 / 98) | |
| KeyboardEvent.js | 29.82% | (34 / 114) | 0% | (0 / 45) | 0% | (0 / 22) | 30.09% | (34 / 113) | |
| KeyboardEventInit.js | 7.55% | (4 / 53) | 0% | (0 / 56) | 0% | (0 / 2) | 7.55% | (4 / 53) | |
| LinkStyle.js | 21.95% | (9 / 41) | 0% | (0 / 16) | 0% | (0 / 9) | 22.5% | (9 / 40) | |
| Location.js | 19.61% | (20 / 102) | 0% | (0 / 40) | 0% | (0 / 29) | 19.8% | (20 / 101) | |
| MessageEvent.js | 21.95% | (18 / 82) | 0% | (0 / 41) | 0% | (0 / 14) | 22.22% | (18 / 81) | |
| MessageEventInit.js | 12.12% | (4 / 33) | 0% | (0 / 38) | 0% | (0 / 2) | 12.12% | (4 / 33) | |
| MouseEvent.js | 22.52% | (25 / 111) | 0% | (0 / 49) | 0% | (0 / 21) | 22.73% | (25 / 110) | |
| MouseEventInit.js | 8.33% | (4 / 48) | 0% | (0 / 50) | 0% | (0 / 2) | 8.33% | (4 / 48) | |
| Navigator.js | 46.55% | (27 / 58) | 0% | (0 / 16) | 0% | (0 / 8) | 47.37% | (27 / 57) | |
| NavigatorConcurrentHardware.js | 21.95% | (9 / 41) | 0% | (0 / 16) | 0% | (0 / 9) | 22.5% | (9 / 40) | |
| NavigatorCookies.js | 21.95% | (9 / 41) | 0% | (0 / 16) | 0% | (0 / 9) | 22.5% | (9 / 40) | |
| NavigatorID.js | 29.82% | (17 / 57) | 0% | (0 / 16) | 0% | (0 / 17) | 30.36% | (17 / 56) | |
| NavigatorLanguage.js | 23.26% | (10 / 43) | 0% | (0 / 16) | 0% | (0 / 10) | 23.81% | (10 / 42) | |
| NavigatorOnLine.js | 21.95% | (9 / 41) | 0% | (0 / 16) | 0% | (0 / 9) | 22.5% | (9 / 40) | |
| NavigatorPlugins.js | 19.57% | (9 / 46) | 0% | (0 / 22) | 0% | (0 / 9) | 20% | (9 / 45) | |
| Node.js | 33.98% | (70 / 206) | 0% | (0 / 112) | 0% | (0 / 33) | 34.15% | (70 / 205) | |
| NonDocumentTypeChildNode.js | 23.26% | (10 / 43) | 0% | (0 / 16) | 0% | (0 / 10) | 23.81% | (10 / 42) | |
| NonElementParentNode.js | 18.37% | (9 / 49) | 0% | (0 / 24) | 0% | (0 / 9) | 18.75% | (9 / 48) | |
| ParentNode.js | 20.9% | (14 / 67) | 0% | (0 / 32) | 0% | (0 / 14) | 21.21% | (14 / 66) | |
| PopStateEvent.js | 23.64% | (13 / 55) | 0% | (0 / 25) | 0% | (0 / 9) | 24.07% | (13 / 54) | |
| PopStateEventInit.js | 23.53% | (4 / 17) | 0% | (0 / 14) | 0% | (0 / 2) | 23.53% | (4 / 17) | |
| ProcessingInstruction.js | 26.67% | (12 / 45) | 0% | (0 / 16) | 0% | (0 / 9) | 27.27% | (12 / 44) | |
| ProgressEvent.js | 25.42% | (15 / 59) | 0% | (0 / 25) | 0% | (0 / 11) | 25.86% | (15 / 58) | |
| ProgressEventInit.js | 14.29% | (4 / 28) | 0% | (0 / 26) | 0% | (0 / 2) | 14.29% | (4 / 28) | |
| Text.js | 21.31% | (13 / 61) | 0% | (0 / 28) | 0% | (0 / 10) | 21.67% | (13 / 60) | |
| TouchEvent.js | 31.58% | (18 / 57) | 0% | (0 / 16) | 0% | (0 / 15) | 32.14% | (18 / 56) | |
| TreeWalker.js | 19.59% | (19 / 97) | 0% | (0 / 58) | 0% | (0 / 20) | 19.79% | (19 / 96) | |
| UIEvent.js | 20.83% | (15 / 72) | 0% | (0 / 37) | 0% | (0 / 11) | 21.13% | (15 / 71) | |
| UIEventInit.js | 17.39% | (4 / 23) | 0% | (0 / 20) | 0% | (0 / 2) | 17.39% | (4 / 23) | |
| WindowEventHandlers.js | 27.38% | (23 / 84) | 0% | (0 / 16) | 0% | (0 / 38) | 27.71% | (23 / 83) | |
| XMLDocument.js | 25.58% | (11 / 43) | 0% | (0 / 16) | 0% | (0 / 8) | 26.19% | (11 / 42) | |
| utils.js | 78.57% | (22 / 28) | 20% | (2 / 10) | 20% | (1 / 5) | 78.57% | (22 / 28) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function Attr() {
throw new TypeError("Illegal constructor");
}
Attr.prototype.toString = function () {
if (this === Attr.prototype) {
return "[object AttrPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(Attr.prototype, "namespaceURI", {
get() {
return this[impl].namespaceURI;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "prefix", {
get() {
return this[impl].prefix;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "localName", {
get() {
return this[impl].localName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "name", {
get() {
return this[impl].name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "nodeName", {
get() {
return this[impl].nodeName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "value", {
get() {
return this[impl].value;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].value = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "nodeValue", {
get() {
return this[impl].nodeValue;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].nodeValue = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "textContent", {
get() {
return this[impl].textContent;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].textContent = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "ownerElement", {
get() {
return utils.tryWrapperForImpl(this[impl].ownerElement);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "specified", {
get() {
return this[impl].specified;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Attr.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Attr.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Attr,
expose: {
Window: { Attr: Attr }
}
};
module.exports = iface;
const Impl = require("../attributes/Attr-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
const convertBlobPropertyBag = require("./BlobPropertyBag").convert;
function Blob() {
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[1] = convertBlobPropertyBag(args[1]);
iface.setup(this, args);
}
Blob.prototype.slice = function slice() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["long long"](args[0], { clamp: true });
}
if (args[1] !== undefined) {
args[1] = conversions["long long"](args[1], { clamp: true });
}
if (args[2] !== undefined) {
args[2] = conversions["DOMString"](args[2]);
}
return utils.tryWrapperForImpl(this[impl].slice.apply(this[impl], args));
};
Blob.prototype.close = function close() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].close.apply(this[impl], args);
};
Blob.prototype.toString = function () {
if (this === Blob.prototype) {
return "[object BlobPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(Blob.prototype, "size", {
get() {
return this[impl].size;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Blob.prototype, "type", {
get() {
return this[impl].type;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Blob.prototype, "isClosed", {
get() {
return this[impl].isClosed;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Blob.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Blob.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Blob,
expose: {
Window: { Blob: Blob },
Worker: { Blob: Blob }
}
};
module.exports = iface;
const Impl = require("../file-api/Blob-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
module.exports = {
convertInherit(obj, ret) {
let key, value;
key = "type";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
} else {
ret[key] = "";
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Text = require("./Text.js");
const impl = utils.implSymbol;
function CDATASection() {
throw new TypeError("Illegal constructor");
}
CDATASection.prototype = Object.create(Text.interface.prototype);
CDATASection.prototype.constructor = CDATASection;
CDATASection.prototype.toString = function () {
if (this === CDATASection.prototype) {
return "[object CDATASectionPrototype]";
}
return Text.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(CDATASection.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(CDATASection.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Text._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: CDATASection,
expose: {
Window: { CDATASection: CDATASection }
}
};
module.exports = iface;
const Impl = require("../nodes/CDATASection-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const ChildNode = require("./ChildNode.js");
const NonDocumentTypeChildNode = require("./NonDocumentTypeChildNode.js");
function CharacterData() {
throw new TypeError("Illegal constructor");
}
CharacterData.prototype = Object.create(Node.interface.prototype);
CharacterData.prototype.constructor = CharacterData;
mixin(CharacterData.prototype, ChildNode.interface.prototype);
ChildNode.mixedInto.push(CharacterData);
mixin(CharacterData.prototype, NonDocumentTypeChildNode.interface.prototype);
NonDocumentTypeChildNode.mixedInto.push(CharacterData);
CharacterData.prototype.substringData = function substringData(offset, count) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'substringData' on 'CharacterData': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
args[1] = conversions["unsigned long"](args[1]);
return this[impl].substringData.apply(this[impl], args);
};
CharacterData.prototype.appendData = function appendData(data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'appendData' on 'CharacterData': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].appendData.apply(this[impl], args);
};
CharacterData.prototype.insertData = function insertData(offset, data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'insertData' on 'CharacterData': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
args[1] = conversions["DOMString"](args[1]);
return this[impl].insertData.apply(this[impl], args);
};
CharacterData.prototype.deleteData = function deleteData(offset, count) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'deleteData' on 'CharacterData': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
args[1] = conversions["unsigned long"](args[1]);
return this[impl].deleteData.apply(this[impl], args);
};
CharacterData.prototype.replaceData = function replaceData(offset, count, data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 3) {
throw new TypeError("Failed to execute 'replaceData' on 'CharacterData': 3 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
args[1] = conversions["unsigned long"](args[1]);
args[2] = conversions["DOMString"](args[2]);
return this[impl].replaceData.apply(this[impl], args);
};
CharacterData.prototype.toString = function () {
if (this === CharacterData.prototype) {
return "[object CharacterDataPrototype]";
}
return Node.interface.prototype.toString.call(this);
};
Object.defineProperty(CharacterData.prototype, "data", {
get() {
return this[impl].data;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].data = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CharacterData.prototype, "length", {
get() {
return this[impl].length;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(CharacterData.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(CharacterData.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Node._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: CharacterData,
expose: {
Window: { CharacterData: CharacterData }
}
};
module.exports = iface;
const Impl = require("../nodes/CharacterData-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function ChildNode() {
throw new TypeError("Illegal constructor");
}
ChildNode.prototype.remove = function remove() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].remove.apply(this[impl], args);
};
ChildNode.prototype.toString = function () {
if (this === ChildNode.prototype) {
return "[object ChildNodePrototype]";
}
return this[impl].toString();
};
ChildNode.prototype[Symbol.unscopables] = {
"remove": true
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(ChildNode.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(ChildNode.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: ChildNode,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/ChildNode-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CharacterData = require("./CharacterData.js");
const impl = utils.implSymbol;
function Comment() {
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
} else {
args[0] = "";
}
iface.setup(this, args);
}
Comment.prototype = Object.create(CharacterData.interface.prototype);
Comment.prototype.constructor = Comment;
Comment.prototype.toString = function () {
if (this === Comment.prototype) {
return "[object CommentPrototype]";
}
return CharacterData.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Comment.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Comment.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
CharacterData._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Comment,
expose: {
Window: { Comment: Comment }
}
};
module.exports = iface;
const Impl = require("../nodes/Comment-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Event = require("./Event.js");
const impl = utils.implSymbol;
const convertCustomEventInit = require("./CustomEventInit").convert;
function CustomEvent(type) {
if (!this || this[impl] || !(this instanceof CustomEvent)) {
throw new TypeError("Failed to construct 'CustomEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'CustomEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertCustomEventInit(args[1]);
iface.setup(this, args);
}
CustomEvent.prototype = Object.create(Event.interface.prototype);
CustomEvent.prototype.constructor = CustomEvent;
CustomEvent.prototype.initCustomEvent = function initCustomEvent(type, bubbles, cancelable, detail) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 4) {
throw new TypeError("Failed to execute 'initCustomEvent' on 'CustomEvent': 4 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 4; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["boolean"](args[1]);
args[2] = conversions["boolean"](args[2]);
args[3] = conversions["any"](args[3]);
return this[impl].initCustomEvent.apply(this[impl], args);
};
CustomEvent.prototype.toString = function () {
if (this === CustomEvent.prototype) {
return "[object CustomEventPrototype]";
}
return Event.interface.prototype.toString.call(this);
};
Object.defineProperty(CustomEvent.prototype, "detail", {
get() {
return this[impl].detail;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(CustomEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(CustomEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Event._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: CustomEvent,
expose: {
Window: { CustomEvent: CustomEvent },
Worker: { CustomEvent: CustomEvent }
}
};
module.exports = iface;
const Impl = require("../events/CustomEvent-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit");
module.exports = {
convertInherit(obj, ret) {
EventInit.convertInherit(obj, ret);
let key, value;
key = "detail";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["any"](value);
} else {
ret[key] = null;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function DOMImplementation() {
throw new TypeError("Illegal constructor");
}
DOMImplementation.prototype.createDocumentType = function createDocumentType(qualifiedName, publicId, systemId) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 3) {
throw new TypeError("Failed to execute 'createDocumentType' on 'DOMImplementation': 3 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["DOMString"](args[1]);
args[2] = conversions["DOMString"](args[2]);
return utils.tryWrapperForImpl(this[impl].createDocumentType.apply(this[impl], args));
};
DOMImplementation.prototype.createDocument = function createDocument(namespace, qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1], { treatNullAsEmptyString: true });
if (args[2] === null || args[2] === undefined) {
args[2] = null;
} else {
}
return utils.tryWrapperForImpl(this[impl].createDocument.apply(this[impl], args));
};
DOMImplementation.prototype.createHTMLDocument = function createHTMLDocument() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
}
return utils.tryWrapperForImpl(this[impl].createHTMLDocument.apply(this[impl], args));
};
DOMImplementation.prototype.hasFeature = function hasFeature() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].hasFeature.apply(this[impl], args);
};
DOMImplementation.prototype.toString = function () {
if (this === DOMImplementation.prototype) {
return "[object DOMImplementationPrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(DOMImplementation.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(DOMImplementation.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: DOMImplementation,
expose: {
Window: { DOMImplementation: DOMImplementation }
}
};
module.exports = iface;
const Impl = require("../nodes/DOMImplementation-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function DOMParser() {
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
iface.setup(this, args);
}
DOMParser.prototype.parseFromString = function parseFromString(str, type) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'parseFromString' on 'DOMParser': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].parseFromString.apply(this[impl], args));
};
DOMParser.prototype.toString = function () {
if (this === DOMParser.prototype) {
return "[object DOMParserPrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(DOMParser.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(DOMParser.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: DOMParser,
expose: {
Window: { DOMParser: DOMParser }
}
};
module.exports = iface;
const Impl = require("../domparsing/DOMParser-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const GlobalEventHandlers = require("./GlobalEventHandlers.js");
const NonElementParentNode = require("./NonElementParentNode.js");
const ParentNode = require("./ParentNode.js");
function Document() {
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
iface.setup(this, args);
}
Document.prototype = Object.create(Node.interface.prototype);
Document.prototype.constructor = Document;
mixin(Document.prototype, GlobalEventHandlers.interface.prototype);
GlobalEventHandlers.mixedInto.push(Document);
mixin(Document.prototype, NonElementParentNode.interface.prototype);
NonElementParentNode.mixedInto.push(Document);
mixin(Document.prototype, ParentNode.interface.prototype);
ParentNode.mixedInto.push(Document);
Document.prototype.getElementsByTagName = function getElementsByTagName(localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getElementsByTagName' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getElementsByTagName.apply(this[impl], args));
};
Document.prototype.getElementsByTagNameNS = function getElementsByTagNameNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'getElementsByTagNameNS' on 'Document': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].getElementsByTagNameNS.apply(this[impl], args));
};
Document.prototype.getElementsByClassName = function getElementsByClassName(classNames) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getElementsByClassName' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getElementsByClassName.apply(this[impl], args));
};
Document.prototype.createElement = function createElement(localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createElement' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createElement.apply(this[impl], args));
};
Document.prototype.createElementNS = function createElementNS(namespace, qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'createElementNS' on 'Document': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].createElementNS.apply(this[impl], args));
};
Document.prototype.createDocumentFragment = function createDocumentFragment() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].createDocumentFragment.apply(this[impl], args));
};
Document.prototype.createTextNode = function createTextNode(data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createTextNode' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createTextNode.apply(this[impl], args));
};
Document.prototype.createCDATASection = function createCDATASection(data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createCDATASection' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createCDATASection.apply(this[impl], args));
};
Document.prototype.createComment = function createComment(data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createComment' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createComment.apply(this[impl], args));
};
Document.prototype.createProcessingInstruction = function createProcessingInstruction(target, data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'createProcessingInstruction' on 'Document': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].createProcessingInstruction.apply(this[impl], args));
};
Document.prototype.importNode = function importNode(node) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'importNode' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[1] !== undefined) {
args[1] = conversions["boolean"](args[1]);
} else {
args[1] = false;
}
return utils.tryWrapperForImpl(this[impl].importNode.apply(this[impl], args));
};
Document.prototype.adoptNode = function adoptNode(node) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'adoptNode' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].adoptNode.apply(this[impl], args));
};
Document.prototype.createAttribute = function createAttribute(localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createAttribute' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createAttribute.apply(this[impl], args));
};
Document.prototype.createAttributeNS = function createAttributeNS(namespace, qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'createAttributeNS' on 'Document': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].createAttributeNS.apply(this[impl], args));
};
Document.prototype.createEvent = function createEvent(_interface) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createEvent' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createEvent.apply(this[impl], args));
};
Document.prototype.createTreeWalker = function createTreeWalker(root) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createTreeWalker' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[1] !== undefined) {
args[1] = conversions["unsigned long"](args[1]);
} else {
args[1] = 4294967295;
}
if (args[2] === null || args[2] === undefined) {
args[2] = null;
} else {
}
return utils.tryWrapperForImpl(this[impl].createTreeWalker.apply(this[impl], args));
};
Document.prototype.getElementsByName = function getElementsByName(elementName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getElementsByName' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getElementsByName.apply(this[impl], args));
};
Document.prototype.open = function open() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
} else {
args[0] = "text/html";
}
if (args[1] !== undefined) {
args[1] = conversions["DOMString"](args[1]);
} else {
args[1] = "";
}
return utils.tryWrapperForImpl(this[impl].open.apply(this[impl], args));
};
Document.prototype.close = function close() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].close.apply(this[impl], args);
};
Document.prototype.write = function write() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
}
return this[impl].write.apply(this[impl], args);
};
Document.prototype.writeln = function writeln() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
}
return this[impl].writeln.apply(this[impl], args);
};
Document.prototype.hasFocus = function hasFocus() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].hasFocus.apply(this[impl], args);
};
Document.prototype.toString = function () {
if (this === Document.prototype) {
return "[object DocumentPrototype]";
}
return Node.interface.prototype.toString.call(this);
};
Object.defineProperty(Document.prototype, "implementation", {
get() {
return utils.tryWrapperForImpl(this[impl].implementation);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "URL", {
get() {
return this[impl].URL;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "documentURI", {
get() {
return this[impl].documentURI;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "origin", {
get() {
return this[impl].origin;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "compatMode", {
get() {
return this[impl].compatMode;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "characterSet", {
get() {
return this[impl].characterSet;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "charset", {
get() {
return this[impl].charset;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "inputEncoding", {
get() {
return this[impl].inputEncoding;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "contentType", {
get() {
return this[impl].contentType;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "doctype", {
get() {
return utils.tryWrapperForImpl(this[impl].doctype);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "documentElement", {
get() {
return utils.tryWrapperForImpl(this[impl].documentElement);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "referrer", {
get() {
return this[impl].referrer;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "cookie", {
get() {
return this[impl].cookie;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].cookie = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "lastModified", {
get() {
return this[impl].lastModified;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "readyState", {
get() {
return utils.tryWrapperForImpl(this[impl].readyState);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "title", {
get() {
return this[impl].title;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].title = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "body", {
get() {
return utils.tryWrapperForImpl(this[impl].body);
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
}
this[impl].body = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "head", {
get() {
return utils.tryWrapperForImpl(this[impl].head);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "images", {
get() {
return utils.tryWrapperForImpl(this[impl].images);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "embeds", {
get() {
return utils.tryWrapperForImpl(this[impl].embeds);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "plugins", {
get() {
return utils.tryWrapperForImpl(this[impl].plugins);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "links", {
get() {
return utils.tryWrapperForImpl(this[impl].links);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "forms", {
get() {
return utils.tryWrapperForImpl(this[impl].forms);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "scripts", {
get() {
return utils.tryWrapperForImpl(this[impl].scripts);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "currentScript", {
get() {
return utils.tryWrapperForImpl(this[impl].currentScript);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "defaultView", {
get() {
return utils.tryWrapperForImpl(this[impl].defaultView);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "activeElement", {
get() {
return utils.tryWrapperForImpl(this[impl].activeElement);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "onreadystatechange", {
get() {
return utils.tryWrapperForImpl(this[impl].onreadystatechange);
},
set(V) {
this[impl].onreadystatechange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "anchors", {
get() {
return utils.tryWrapperForImpl(this[impl].anchors);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "applets", {
get() {
return utils.tryWrapperForImpl(this[impl].applets);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "styleSheets", {
get() {
return utils.tryWrapperForImpl(this[impl].styleSheets);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "hidden", {
get() {
return this[impl].hidden;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "visibilityState", {
get() {
return utils.tryWrapperForImpl(this[impl].visibilityState);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "onvisibilitychange", {
get() {
return utils.tryWrapperForImpl(this[impl].onvisibilitychange);
},
set(V) {
this[impl].onvisibilitychange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Document.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Document.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Node._internalSetup(obj);
Object.defineProperty(obj, "location", {
get() {
return utils.tryWrapperForImpl(obj[impl].location);
},
set(V) {
this.location.href = V;
},
enumerable: true,
configurable: false
});
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Document,
expose: {
Window: { Document: Document }
}
};
module.exports = iface;
const Impl = require("../nodes/Document-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const ParentNode = require("./ParentNode.js");
function DocumentFragment() {
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
iface.setup(this, args);
}
DocumentFragment.prototype = Object.create(Node.interface.prototype);
DocumentFragment.prototype.constructor = DocumentFragment;
mixin(DocumentFragment.prototype, ParentNode.interface.prototype);
ParentNode.mixedInto.push(DocumentFragment);
DocumentFragment.prototype.toString = function () {
if (this === DocumentFragment.prototype) {
return "[object DocumentFragmentPrototype]";
}
return Node.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(DocumentFragment.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(DocumentFragment.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Node._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: DocumentFragment,
expose: {
Window: { DocumentFragment: DocumentFragment }
}
};
module.exports = iface;
const Impl = require("../nodes/DocumentFragment-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const ChildNode = require("./ChildNode.js");
function DocumentType() {
throw new TypeError("Illegal constructor");
}
DocumentType.prototype = Object.create(Node.interface.prototype);
DocumentType.prototype.constructor = DocumentType;
mixin(DocumentType.prototype, ChildNode.interface.prototype);
ChildNode.mixedInto.push(DocumentType);
DocumentType.prototype.toString = function () {
if (this === DocumentType.prototype) {
return "[object DocumentTypePrototype]";
}
return Node.interface.prototype.toString.call(this);
};
Object.defineProperty(DocumentType.prototype, "name", {
get() {
return this[impl].name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DocumentType.prototype, "publicId", {
get() {
return this[impl].publicId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DocumentType.prototype, "systemId", {
get() {
return this[impl].systemId;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(DocumentType.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(DocumentType.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Node._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: DocumentType,
expose: {
Window: { DocumentType: DocumentType }
}
};
module.exports = iface;
const Impl = require("../nodes/DocumentType-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const ChildNode = require("./ChildNode.js");
const NonDocumentTypeChildNode = require("./NonDocumentTypeChildNode.js");
const ParentNode = require("./ParentNode.js");
function Element() {
throw new TypeError("Illegal constructor");
}
Element.prototype = Object.create(Node.interface.prototype);
Element.prototype.constructor = Element;
mixin(Element.prototype, ChildNode.interface.prototype);
ChildNode.mixedInto.push(Element);
mixin(Element.prototype, NonDocumentTypeChildNode.interface.prototype);
NonDocumentTypeChildNode.mixedInto.push(Element);
mixin(Element.prototype, ParentNode.interface.prototype);
ParentNode.mixedInto.push(Element);
Element.prototype.hasAttributes = function hasAttributes() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].hasAttributes.apply(this[impl], args);
};
Element.prototype.getAttributeNames = function getAttributeNames() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].getAttributeNames.apply(this[impl], args));
};
Element.prototype.getAttribute = function getAttribute(qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getAttribute' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].getAttribute.apply(this[impl], args);
};
Element.prototype.getAttributeNS = function getAttributeNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'getAttributeNS' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return this[impl].getAttributeNS.apply(this[impl], args);
};
Element.prototype.setAttribute = function setAttribute(qualifiedName, value) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'setAttribute' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["DOMString"](args[1]);
return this[impl].setAttribute.apply(this[impl], args);
};
Element.prototype.setAttributeNS = function setAttributeNS(namespace, qualifiedName, value) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 3) {
throw new TypeError("Failed to execute 'setAttributeNS' on 'Element': 3 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
args[2] = conversions["DOMString"](args[2]);
return this[impl].setAttributeNS.apply(this[impl], args);
};
Element.prototype.removeAttribute = function removeAttribute(qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'removeAttribute' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].removeAttribute.apply(this[impl], args);
};
Element.prototype.removeAttributeNS = function removeAttributeNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'removeAttributeNS' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return this[impl].removeAttributeNS.apply(this[impl], args);
};
Element.prototype.hasAttribute = function hasAttribute(qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'hasAttribute' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].hasAttribute.apply(this[impl], args);
};
Element.prototype.hasAttributeNS = function hasAttributeNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'hasAttributeNS' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return this[impl].hasAttributeNS.apply(this[impl], args);
};
Element.prototype.getAttributeNode = function getAttributeNode(qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getAttributeNode' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getAttributeNode.apply(this[impl], args));
};
Element.prototype.getAttributeNodeNS = function getAttributeNodeNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'getAttributeNodeNS' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].getAttributeNodeNS.apply(this[impl], args));
};
Element.prototype.setAttributeNode = function setAttributeNode(attr) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'setAttributeNode' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].setAttributeNode.apply(this[impl], args));
};
Element.prototype.setAttributeNodeNS = function setAttributeNodeNS(attr) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'setAttributeNodeNS' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].setAttributeNodeNS.apply(this[impl], args));
};
Element.prototype.removeAttributeNode = function removeAttributeNode(attr) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'removeAttributeNode' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].removeAttributeNode.apply(this[impl], args));
};
Element.prototype.matches = function matches(selectors) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'matches' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].matches.apply(this[impl], args);
};
Element.prototype.webkitMatchesSelector = function webkitMatchesSelector(selectors) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'webkitMatchesSelector' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].webkitMatchesSelector.apply(this[impl], args);
};
Element.prototype.getElementsByTagName = function getElementsByTagName(localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getElementsByTagName' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getElementsByTagName.apply(this[impl], args));
};
Element.prototype.getElementsByTagNameNS = function getElementsByTagNameNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'getElementsByTagNameNS' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].getElementsByTagNameNS.apply(this[impl], args));
};
Element.prototype.getElementsByClassName = function getElementsByClassName(classNames) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getElementsByClassName' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getElementsByClassName.apply(this[impl], args));
};
Element.prototype.insertAdjacentHTML = function insertAdjacentHTML(position, text) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'insertAdjacentHTML' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["DOMString"](args[1]);
return this[impl].insertAdjacentHTML.apply(this[impl], args);
};
Element.prototype.getClientRects = function getClientRects() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].getClientRects.apply(this[impl], args));
};
Element.prototype.getBoundingClientRect = function getBoundingClientRect() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].getBoundingClientRect.apply(this[impl], args));
};
Element.prototype.toString = function () {
if (this === Element.prototype) {
return "[object ElementPrototype]";
}
return Node.interface.prototype.toString.call(this);
};
Object.defineProperty(Element.prototype, "namespaceURI", {
get() {
return this[impl].namespaceURI;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "prefix", {
get() {
return this[impl].prefix;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "localName", {
get() {
return this[impl].localName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "tagName", {
get() {
return this[impl].tagName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "id", {
get() {
const value = this.getAttribute("id");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("id", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "className", {
get() {
const value = this.getAttribute("class");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("class", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "classList", {
get() {
return utils.tryWrapperForImpl(this[impl].classList);
},
set(V) {
this.classList.value = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "attributes", {
get() {
return utils.tryWrapperForImpl(this[impl].attributes);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "innerHTML", {
get() {
return this[impl].innerHTML;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].innerHTML = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "outerHTML", {
get() {
return this[impl].outerHTML;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].outerHTML = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "scrollTop", {
get() {
return this[impl].scrollTop;
},
set(V) {
V = conversions["unrestricted double"](V);
this[impl].scrollTop = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "scrollLeft", {
get() {
return this[impl].scrollLeft;
},
set(V) {
V = conversions["unrestricted double"](V);
this[impl].scrollLeft = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "scrollWidth", {
get() {
return this[impl].scrollWidth;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "scrollHeight", {
get() {
return this[impl].scrollHeight;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "clientTop", {
get() {
return this[impl].clientTop;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "clientLeft", {
get() {
return this[impl].clientLeft;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "clientWidth", {
get() {
return this[impl].clientWidth;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "clientHeight", {
get() {
return this[impl].clientHeight;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Element.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Element.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Node._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Element,
expose: {
Window: { Element: Element }
}
};
module.exports = iface;
const Impl = require("../nodes/Element-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function ElementCSSInlineStyle() {
throw new TypeError("Illegal constructor");
}
ElementCSSInlineStyle.prototype.toString = function () {
if (this === ElementCSSInlineStyle.prototype) {
return "[object ElementCSSInlineStylePrototype]";
}
return this[impl].toString();
};
Object.defineProperty(ElementCSSInlineStyle.prototype, "style", {
get() {
return utils.tryWrapperForImpl(this[impl].style);
},
set(V) {
this.style.cssText = V;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(ElementCSSInlineStyle.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(ElementCSSInlineStyle.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: ElementCSSInlineStyle,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/ElementCSSInlineStyle-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function ElementContentEditable() {
throw new TypeError("Illegal constructor");
}
ElementContentEditable.prototype.toString = function () {
if (this === ElementContentEditable.prototype) {
return "[object ElementContentEditablePrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(ElementContentEditable.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(ElementContentEditable.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: ElementContentEditable,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/ElementContentEditable-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Event = require("./Event.js");
const impl = utils.implSymbol;
const convertErrorEventInit = require("./ErrorEventInit").convert;
function ErrorEvent(type) {
if (!this || this[impl] || !(this instanceof ErrorEvent)) {
throw new TypeError("Failed to construct 'ErrorEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'ErrorEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertErrorEventInit(args[1]);
iface.setup(this, args);
}
ErrorEvent.prototype = Object.create(Event.interface.prototype);
ErrorEvent.prototype.constructor = ErrorEvent;
ErrorEvent.prototype.toString = function () {
if (this === ErrorEvent.prototype) {
return "[object ErrorEventPrototype]";
}
return Event.interface.prototype.toString.call(this);
};
Object.defineProperty(ErrorEvent.prototype, "message", {
get() {
return this[impl].message;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorEvent.prototype, "filename", {
get() {
return this[impl].filename;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorEvent.prototype, "lineno", {
get() {
return this[impl].lineno;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorEvent.prototype, "colno", {
get() {
return this[impl].colno;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorEvent.prototype, "error", {
get() {
return this[impl].error;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(ErrorEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(ErrorEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Event._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: ErrorEvent,
expose: {
Window: { ErrorEvent: ErrorEvent },
Worker: { ErrorEvent: ErrorEvent }
}
};
module.exports = iface;
const Impl = require("../events/ErrorEvent-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit");
module.exports = {
convertInherit(obj, ret) {
EventInit.convertInherit(obj, ret);
let key, value;
key = "colno";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["unsigned long"](value);
}
key = "error";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["any"](value);
}
key = "filename";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
}
key = "lineno";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["unsigned long"](value);
}
key = "message";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
const convertEventInit = require("./EventInit").convert;
function Event(type) {
if (!this || this[impl] || !(this instanceof Event)) {
throw new TypeError("Failed to construct 'Event': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'Event': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertEventInit(args[1]);
iface.setup(this, args);
}
Event.prototype.stopPropagation = function stopPropagation() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].stopPropagation.apply(this[impl], args);
};
Event.prototype.stopImmediatePropagation = function stopImmediatePropagation() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].stopImmediatePropagation.apply(this[impl], args);
};
Event.prototype.preventDefault = function preventDefault() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].preventDefault.apply(this[impl], args);
};
Event.prototype.initEvent = function initEvent(type, bubbles, cancelable) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 3) {
throw new TypeError("Failed to execute 'initEvent' on 'Event': 3 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["boolean"](args[1]);
args[2] = conversions["boolean"](args[2]);
return this[impl].initEvent.apply(this[impl], args);
};
Event.prototype.toString = function () {
if (this === Event.prototype) {
return "[object EventPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(Event.prototype, "type", {
get() {
return this[impl].type;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "target", {
get() {
return utils.tryWrapperForImpl(this[impl].target);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "currentTarget", {
get() {
return utils.tryWrapperForImpl(this[impl].currentTarget);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event, "NONE", {
value: 0,
enumerable: true
});
Object.defineProperty(Event.prototype, "NONE", {
value: 0,
enumerable: true
});
Object.defineProperty(Event, "CAPTURING_PHASE", {
value: 1,
enumerable: true
});
Object.defineProperty(Event.prototype, "CAPTURING_PHASE", {
value: 1,
enumerable: true
});
Object.defineProperty(Event, "AT_TARGET", {
value: 2,
enumerable: true
});
Object.defineProperty(Event.prototype, "AT_TARGET", {
value: 2,
enumerable: true
});
Object.defineProperty(Event, "BUBBLING_PHASE", {
value: 3,
enumerable: true
});
Object.defineProperty(Event.prototype, "BUBBLING_PHASE", {
value: 3,
enumerable: true
});
Object.defineProperty(Event.prototype, "eventPhase", {
get() {
return this[impl].eventPhase;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "cancelBubble", {
get() {
return this[impl].cancelBubble;
},
set(V) {
V = conversions["boolean"](V);
this[impl].cancelBubble = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "bubbles", {
get() {
return this[impl].bubbles;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "cancelable", {
get() {
return this[impl].cancelable;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "defaultPrevented", {
get() {
return this[impl].defaultPrevented;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "timeStamp", {
get() {
return this[impl].timeStamp;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Event.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Event.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Object.defineProperty(obj, "isTrusted", {
get() {
return obj[impl].isTrusted;
},
enumerable: true,
configurable: false
});
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Event,
expose: {
Window: { Event: Event },
Worker: { Event: Event }
}
};
module.exports = iface;
const Impl = require("../events/Event-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
module.exports = {
convertInherit(obj, ret) {
let key, value;
key = "bubbles";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "cancelable";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEventInit = require("./UIEventInit");
module.exports = {
convertInherit(obj, ret) {
UIEventInit.convertInherit(obj, ret);
let key, value;
key = "altKey";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "ctrlKey";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "metaKey";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierAltGraph";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierCapsLock";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierFn";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierFnLock";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierHyper";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierNumLock";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierOS";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierScrollLock";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierSuper";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierSymbol";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierSymbolLock";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "shiftKey";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function EventTarget() {
throw new TypeError("Illegal constructor");
}
EventTarget.prototype.addEventListener = function addEventListener(type, callback) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
if (args[1] === null || args[1] === undefined) {
args[1] = null;
} else {
}
return this[impl].addEventListener.apply(this[impl], args);
};
EventTarget.prototype.removeEventListener = function removeEventListener(type, callback) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
if (args[1] === null || args[1] === undefined) {
args[1] = null;
} else {
}
return this[impl].removeEventListener.apply(this[impl], args);
};
EventTarget.prototype.dispatchEvent = function dispatchEvent(event) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'dispatchEvent' on 'EventTarget': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].dispatchEvent.apply(this[impl], args);
};
EventTarget.prototype.toString = function () {
if (this === EventTarget.prototype) {
return "[object EventTargetPrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(EventTarget.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(EventTarget.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: EventTarget,
expose: {
Window: { EventTarget: EventTarget },
Worker: { EventTarget: EventTarget }
}
};
module.exports = iface;
const Impl = require("../events/EventTarget-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Blob = require("./Blob.js");
const impl = utils.implSymbol;
const convertFilePropertyBag = require("./FilePropertyBag").convert;
function File(fileBits, fileName) {
if (!this || this[impl] || !(this instanceof File)) {
throw new TypeError("Failed to construct 'File': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 2) {
throw new TypeError("Failed to construct 'File': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[1] = conversions["USVString"](args[1]);
args[2] = convertFilePropertyBag(args[2]);
iface.setup(this, args);
}
File.prototype = Object.create(Blob.interface.prototype);
File.prototype.constructor = File;
File.prototype.toString = function () {
if (this === File.prototype) {
return "[object FilePrototype]";
}
return Blob.interface.prototype.toString.call(this);
};
Object.defineProperty(File.prototype, "name", {
get() {
return this[impl].name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(File.prototype, "lastModified", {
get() {
return this[impl].lastModified;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(File.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(File.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Blob._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: File,
expose: {
Window: { File: File },
Worker: { File: File }
}
};
module.exports = iface;
const Impl = require("../file-api/File-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function FileList() {
throw new TypeError("Illegal constructor");
}
FileList.prototype.item = function item(index) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'item' on 'FileList': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
return utils.tryWrapperForImpl(this[impl].item.apply(this[impl], args));
};
FileList.prototype.toString = function () {
if (this === FileList.prototype) {
return "[object FileListPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(FileList.prototype, "length", {
get() {
return this[impl].length;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(FileList.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(FileList.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: FileList,
expose: {
Window: { FileList: FileList },
Worker: { FileList: FileList }
}
};
module.exports = iface;
const Impl = require("../file-api/FileList-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const BlobPropertyBag = require("./BlobPropertyBag");
module.exports = {
convertInherit(obj, ret) {
BlobPropertyBag.convertInherit(obj, ret);
let key, value;
key = "lastModified";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["long long"](value);
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventTarget = require("./EventTarget.js");
const impl = utils.implSymbol;
module.exports = {
createInterface: function (defaultPrivateData) {
defaultPrivateData = defaultPrivateData === undefined ? {} : defaultPrivateData;
function FileReader() {
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
iface.setup(this, args);
}
FileReader.prototype = Object.create(EventTarget.interface.prototype);
FileReader.prototype.constructor = FileReader;
FileReader.prototype.readAsArrayBuffer = function readAsArrayBuffer(blob) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'readAsArrayBuffer' on 'FileReader': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].readAsArrayBuffer.apply(this[impl], args);
};
FileReader.prototype.readAsText = function readAsText(blob) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'readAsText' on 'FileReader': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[1] !== undefined) {
args[1] = conversions["DOMString"](args[1]);
}
return this[impl].readAsText.apply(this[impl], args);
};
FileReader.prototype.readAsDataURL = function readAsDataURL(blob) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'readAsDataURL' on 'FileReader': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].readAsDataURL.apply(this[impl], args);
};
FileReader.prototype.abort = function abort() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].abort.apply(this[impl], args);
};
FileReader.prototype.toString = function () {
if (this === FileReader.prototype) {
return "[object FileReaderPrototype]";
}
return EventTarget.interface.prototype.toString.call(this);
};
Object.defineProperty(FileReader, "EMPTY", {
value: 0,
enumerable: true
});
Object.defineProperty(FileReader.prototype, "EMPTY", {
value: 0,
enumerable: true
});
Object.defineProperty(FileReader, "LOADING", {
value: 1,
enumerable: true
});
Object.defineProperty(FileReader.prototype, "LOADING", {
value: 1,
enumerable: true
});
Object.defineProperty(FileReader, "DONE", {
value: 2,
enumerable: true
});
Object.defineProperty(FileReader.prototype, "DONE", {
value: 2,
enumerable: true
});
Object.defineProperty(FileReader.prototype, "readyState", {
get() {
return this[impl].readyState;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "result", {
get() {
return utils.tryWrapperForImpl(this[impl].result);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "error", {
get() {
return utils.tryWrapperForImpl(this[impl].error);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onloadstart", {
get() {
return utils.tryWrapperForImpl(this[impl].onloadstart);
},
set(V) {
this[impl].onloadstart = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onprogress", {
get() {
return utils.tryWrapperForImpl(this[impl].onprogress);
},
set(V) {
this[impl].onprogress = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onload", {
get() {
return utils.tryWrapperForImpl(this[impl].onload);
},
set(V) {
this[impl].onload = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onabort", {
get() {
return utils.tryWrapperForImpl(this[impl].onabort);
},
set(V) {
this[impl].onabort = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onerror", {
get() {
return utils.tryWrapperForImpl(this[impl].onerror);
},
set(V) {
this[impl].onerror = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onloadend", {
get() {
return utils.tryWrapperForImpl(this[impl].onloadend);
},
set(V) {
this[impl].onloadend = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
const iface = {
create(constructorArgs, privateData) {
let obj = Object.create(FileReader.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(FileReader.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
EventTarget._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
for (var prop in defaultPrivateData) {
if (!(prop in privateData)) {
privateData[prop] = defaultPrivateData[prop];
}
}
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: FileReader,
expose: {
Window: { FileReader: FileReader },
Worker: { FileReader: FileReader }
}
};
return iface;
},
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
};
const Impl = require("../file-api/FileReader-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEvent = require("./UIEvent.js");
const impl = utils.implSymbol;
const convertFocusEventInit = require("./FocusEventInit").convert;
function FocusEvent(type) {
if (!this || this[impl] || !(this instanceof FocusEvent)) {
throw new TypeError("Failed to construct 'FocusEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'FocusEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertFocusEventInit(args[1]);
iface.setup(this, args);
}
FocusEvent.prototype = Object.create(UIEvent.interface.prototype);
FocusEvent.prototype.constructor = FocusEvent;
FocusEvent.prototype.toString = function () {
if (this === FocusEvent.prototype) {
return "[object FocusEventPrototype]";
}
return UIEvent.interface.prototype.toString.call(this);
};
Object.defineProperty(FocusEvent.prototype, "relatedTarget", {
get() {
return utils.tryWrapperForImpl(this[impl].relatedTarget);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(FocusEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(FocusEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
UIEvent._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: FocusEvent,
expose: {
Window: { FocusEvent: FocusEvent }
}
};
module.exports = iface;
const Impl = require("../events/FocusEvent-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEventInit = require("./UIEventInit");
module.exports = {
convertInherit(obj, ret) {
UIEventInit.convertInherit(obj, ret);
let key, value;
key = "relatedTarget";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = (value);
} else {
ret[key] = null;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function FormData() {
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
iface.setup(this, args);
}
FormData.prototype.append = function append(name, value) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'append' on 'FormData': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
if (args[2] !== undefined) {
args[2] = conversions["USVString"](args[2]);
}
return this[impl].append.apply(this[impl], args);
};
FormData.prototype.delete = function _(name) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'delete' on 'FormData': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
return this[impl].delete.apply(this[impl], args);
};
FormData.prototype.get = function get(name) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'get' on 'FormData': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
return utils.tryWrapperForImpl(this[impl].get.apply(this[impl], args));
};
FormData.prototype.getAll = function getAll(name) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getAll' on 'FormData': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getAll.apply(this[impl], args));
};
FormData.prototype.has = function has(name) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'has' on 'FormData': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
return this[impl].has.apply(this[impl], args);
};
FormData.prototype.set = function set(name, value) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'set' on 'FormData': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
if (args[2] !== undefined) {
args[2] = conversions["USVString"](args[2]);
}
return this[impl].set.apply(this[impl], args);
};
FormData.prototype.toString = function () {
if (this === FormData.prototype) {
return "[object FormDataPrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(FormData.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(FormData.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: FormData,
expose: {
Window: { FormData: FormData },
Worker: { FormData: FormData }
}
};
module.exports = iface;
const Impl = require("../xhr/FormData-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function GlobalEventHandlers() {
throw new TypeError("Illegal constructor");
}
GlobalEventHandlers.prototype.toString = function () {
if (this === GlobalEventHandlers.prototype) {
return "[object GlobalEventHandlersPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(GlobalEventHandlers.prototype, "onabort", {
get() {
return utils.tryWrapperForImpl(this[impl].onabort);
},
set(V) {
this[impl].onabort = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onautocomplete", {
get() {
return utils.tryWrapperForImpl(this[impl].onautocomplete);
},
set(V) {
this[impl].onautocomplete = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onautocompleteerror", {
get() {
return utils.tryWrapperForImpl(this[impl].onautocompleteerror);
},
set(V) {
this[impl].onautocompleteerror = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onblur", {
get() {
return utils.tryWrapperForImpl(this[impl].onblur);
},
set(V) {
this[impl].onblur = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oncancel", {
get() {
return utils.tryWrapperForImpl(this[impl].oncancel);
},
set(V) {
this[impl].oncancel = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oncanplay", {
get() {
return utils.tryWrapperForImpl(this[impl].oncanplay);
},
set(V) {
this[impl].oncanplay = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oncanplaythrough", {
get() {
return utils.tryWrapperForImpl(this[impl].oncanplaythrough);
},
set(V) {
this[impl].oncanplaythrough = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onchange", {
get() {
return utils.tryWrapperForImpl(this[impl].onchange);
},
set(V) {
this[impl].onchange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onclick", {
get() {
return utils.tryWrapperForImpl(this[impl].onclick);
},
set(V) {
this[impl].onclick = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onclose", {
get() {
return utils.tryWrapperForImpl(this[impl].onclose);
},
set(V) {
this[impl].onclose = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oncontextmenu", {
get() {
return utils.tryWrapperForImpl(this[impl].oncontextmenu);
},
set(V) {
this[impl].oncontextmenu = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oncuechange", {
get() {
return utils.tryWrapperForImpl(this[impl].oncuechange);
},
set(V) {
this[impl].oncuechange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondblclick", {
get() {
return utils.tryWrapperForImpl(this[impl].ondblclick);
},
set(V) {
this[impl].ondblclick = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondrag", {
get() {
return utils.tryWrapperForImpl(this[impl].ondrag);
},
set(V) {
this[impl].ondrag = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragend", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragend);
},
set(V) {
this[impl].ondragend = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragenter", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragenter);
},
set(V) {
this[impl].ondragenter = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragexit", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragexit);
},
set(V) {
this[impl].ondragexit = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragleave", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragleave);
},
set(V) {
this[impl].ondragleave = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragover", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragover);
},
set(V) {
this[impl].ondragover = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragstart", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragstart);
},
set(V) {
this[impl].ondragstart = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondrop", {
get() {
return utils.tryWrapperForImpl(this[impl].ondrop);
},
set(V) {
this[impl].ondrop = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondurationchange", {
get() {
return utils.tryWrapperForImpl(this[impl].ondurationchange);
},
set(V) {
this[impl].ondurationchange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onemptied", {
get() {
return utils.tryWrapperForImpl(this[impl].onemptied);
},
set(V) {
this[impl].onemptied = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onended", {
get() {
return utils.tryWrapperForImpl(this[impl].onended);
},
set(V) {
this[impl].onended = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onerror", {
get() {
return utils.tryWrapperForImpl(this[impl].onerror);
},
set(V) {
this[impl].onerror = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onfocus", {
get() {
return utils.tryWrapperForImpl(this[impl].onfocus);
},
set(V) {
this[impl].onfocus = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oninput", {
get() {
return utils.tryWrapperForImpl(this[impl].oninput);
},
set(V) {
this[impl].oninput = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oninvalid", {
get() {
return utils.tryWrapperForImpl(this[impl].oninvalid);
},
set(V) {
this[impl].oninvalid = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onkeydown", {
get() {
return utils.tryWrapperForImpl(this[impl].onkeydown);
},
set(V) {
this[impl].onkeydown = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onkeypress", {
get() {
return utils.tryWrapperForImpl(this[impl].onkeypress);
},
set(V) {
this[impl].onkeypress = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onkeyup", {
get() {
return utils.tryWrapperForImpl(this[impl].onkeyup);
},
set(V) {
this[impl].onkeyup = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onload", {
get() {
return utils.tryWrapperForImpl(this[impl].onload);
},
set(V) {
this[impl].onload = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onloadeddata", {
get() {
return utils.tryWrapperForImpl(this[impl].onloadeddata);
},
set(V) {
this[impl].onloadeddata = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onloadedmetadata", {
get() {
return utils.tryWrapperForImpl(this[impl].onloadedmetadata);
},
set(V) {
this[impl].onloadedmetadata = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onloadstart", {
get() {
return utils.tryWrapperForImpl(this[impl].onloadstart);
},
set(V) {
this[impl].onloadstart = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmousedown", {
get() {
return utils.tryWrapperForImpl(this[impl].onmousedown);
},
set(V) {
this[impl].onmousedown = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmouseenter", {
get() {
return utils.tryWrapperForImpl(this[impl].onmouseenter);
},
set(V) {
this[impl].onmouseenter = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmouseleave", {
get() {
return utils.tryWrapperForImpl(this[impl].onmouseleave);
},
set(V) {
this[impl].onmouseleave = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmousemove", {
get() {
return utils.tryWrapperForImpl(this[impl].onmousemove);
},
set(V) {
this[impl].onmousemove = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmouseout", {
get() {
return utils.tryWrapperForImpl(this[impl].onmouseout);
},
set(V) {
this[impl].onmouseout = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmouseover", {
get() {
return utils.tryWrapperForImpl(this[impl].onmouseover);
},
set(V) {
this[impl].onmouseover = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmouseup", {
get() {
return utils.tryWrapperForImpl(this[impl].onmouseup);
},
set(V) {
this[impl].onmouseup = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onwheel", {
get() {
return utils.tryWrapperForImpl(this[impl].onwheel);
},
set(V) {
this[impl].onwheel = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onpause", {
get() {
return utils.tryWrapperForImpl(this[impl].onpause);
},
set(V) {
this[impl].onpause = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onplay", {
get() {
return utils.tryWrapperForImpl(this[impl].onplay);
},
set(V) {
this[impl].onplay = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onplaying", {
get() {
return utils.tryWrapperForImpl(this[impl].onplaying);
},
set(V) {
this[impl].onplaying = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onprogress", {
get() {
return utils.tryWrapperForImpl(this[impl].onprogress);
},
set(V) {
this[impl].onprogress = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onratechange", {
get() {
return utils.tryWrapperForImpl(this[impl].onratechange);
},
set(V) {
this[impl].onratechange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onreset", {
get() {
return utils.tryWrapperForImpl(this[impl].onreset);
},
set(V) {
this[impl].onreset = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onresize", {
get() {
return utils.tryWrapperForImpl(this[impl].onresize);
},
set(V) {
this[impl].onresize = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onscroll", {
get() {
return utils.tryWrapperForImpl(this[impl].onscroll);
},
set(V) {
this[impl].onscroll = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onseeked", {
get() {
return utils.tryWrapperForImpl(this[impl].onseeked);
},
set(V) {
this[impl].onseeked = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onseeking", {
get() {
return utils.tryWrapperForImpl(this[impl].onseeking);
},
set(V) {
this[impl].onseeking = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onselect", {
get() {
return utils.tryWrapperForImpl(this[impl].onselect);
},
set(V) {
this[impl].onselect = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onshow", {
get() {
return utils.tryWrapperForImpl(this[impl].onshow);
},
set(V) {
this[impl].onshow = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onsort", {
get() {
return utils.tryWrapperForImpl(this[impl].onsort);
},
set(V) {
this[impl].onsort = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onstalled", {
get() {
return utils.tryWrapperForImpl(this[impl].onstalled);
},
set(V) {
this[impl].onstalled = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onsubmit", {
get() {
return utils.tryWrapperForImpl(this[impl].onsubmit);
},
set(V) {
this[impl].onsubmit = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onsuspend", {
get() {
return utils.tryWrapperForImpl(this[impl].onsuspend);
},
set(V) {
this[impl].onsuspend = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ontimeupdate", {
get() {
return utils.tryWrapperForImpl(this[impl].ontimeupdate);
},
set(V) {
this[impl].ontimeupdate = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ontoggle", {
get() {
return utils.tryWrapperForImpl(this[impl].ontoggle);
},
set(V) {
this[impl].ontoggle = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onvolumechange", {
get() {
return utils.tryWrapperForImpl(this[impl].onvolumechange);
},
set(V) {
this[impl].onvolumechange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onwaiting", {
get() {
return utils.tryWrapperForImpl(this[impl].onwaiting);
},
set(V) {
this[impl].onwaiting = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(GlobalEventHandlers.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(GlobalEventHandlers.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: GlobalEventHandlers,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/GlobalEventHandlers-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const HTMLHyperlinkElementUtils = require("./HTMLHyperlinkElementUtils.js");
function HTMLAnchorElement() {
throw new TypeError("Illegal constructor");
}
HTMLAnchorElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLAnchorElement.prototype.constructor = HTMLAnchorElement;
mixin(HTMLAnchorElement.prototype, HTMLHyperlinkElementUtils.interface.prototype);
HTMLHyperlinkElementUtils.mixedInto.push(HTMLAnchorElement);
HTMLAnchorElement.prototype.toString = function () {
if (this === HTMLAnchorElement.prototype) {
return "[object HTMLAnchorElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLAnchorElement.prototype, "target", {
get() {
const value = this.getAttribute("target");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("target", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "download", {
get() {
const value = this.getAttribute("download");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("download", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "rel", {
get() {
const value = this.getAttribute("rel");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("rel", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "hreflang", {
get() {
const value = this.getAttribute("hreflang");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("hreflang", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "text", {
get() {
return this[impl].text;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].text = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "coords", {
get() {
const value = this.getAttribute("coords");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("coords", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "charset", {
get() {
const value = this.getAttribute("charset");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("charset", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "rev", {
get() {
const value = this.getAttribute("rev");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("rev", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "shape", {
get() {
const value = this.getAttribute("shape");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("shape", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLAnchorElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLAnchorElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLAnchorElement,
expose: {
Window: { HTMLAnchorElement: HTMLAnchorElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLAnchorElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLAppletElement() {
throw new TypeError("Illegal constructor");
}
HTMLAppletElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLAppletElement.prototype.constructor = HTMLAppletElement;
HTMLAppletElement.prototype.toString = function () {
if (this === HTMLAppletElement.prototype) {
return "[object HTMLAppletElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLAppletElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "alt", {
get() {
const value = this.getAttribute("alt");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("alt", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "archive", {
get() {
const value = this.getAttribute("archive");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("archive", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "code", {
get() {
const value = this.getAttribute("code");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("code", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "codeBase", {
get() {
return this[impl].codeBase;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].codeBase = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "height", {
get() {
const value = this.getAttribute("height");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("height", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "hspace", {
get() {
const value = parseInt(this.getAttribute("hspace"));
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["unsigned long"](V);
V = V > 2147483647 ? 0 : V;
this.setAttribute("hspace", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "object", {
get() {
return this[impl].object;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].object = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "vspace", {
get() {
const value = parseInt(this.getAttribute("vspace"));
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["unsigned long"](V);
V = V > 2147483647 ? 0 : V;
this.setAttribute("vspace", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLAppletElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLAppletElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLAppletElement,
expose: {
Window: { HTMLAppletElement: HTMLAppletElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLAppletElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const HTMLHyperlinkElementUtils = require("./HTMLHyperlinkElementUtils.js");
function HTMLAreaElement() {
throw new TypeError("Illegal constructor");
}
HTMLAreaElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLAreaElement.prototype.constructor = HTMLAreaElement;
mixin(HTMLAreaElement.prototype, HTMLHyperlinkElementUtils.interface.prototype);
HTMLHyperlinkElementUtils.mixedInto.push(HTMLAreaElement);
HTMLAreaElement.prototype.toString = function () {
if (this === HTMLAreaElement.prototype) {
return "[object HTMLAreaElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLAreaElement.prototype, "alt", {
get() {
const value = this.getAttribute("alt");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("alt", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAreaElement.prototype, "coords", {
get() {
const value = this.getAttribute("coords");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("coords", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAreaElement.prototype, "shape", {
get() {
const value = this.getAttribute("shape");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("shape", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAreaElement.prototype, "target", {
get() {
const value = this.getAttribute("target");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("target", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAreaElement.prototype, "rel", {
get() {
const value = this.getAttribute("rel");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("rel", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAreaElement.prototype, "noHref", {
get() {
return this.hasAttribute("noHref");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("noHref", "");
} else {
this.removeAttribute("noHref");
}
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLAreaElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLAreaElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLAreaElement,
expose: {
Window: { HTMLAreaElement: HTMLAreaElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLAreaElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLMediaElement = require("./HTMLMediaElement.js");
const impl = utils.implSymbol;
function HTMLAudioElement() {
throw new TypeError("Illegal constructor");
}
HTMLAudioElement.prototype = Object.create(HTMLMediaElement.interface.prototype);
HTMLAudioElement.prototype.constructor = HTMLAudioElement;
HTMLAudioElement.prototype.toString = function () {
if (this === HTMLAudioElement.prototype) {
return "[object HTMLAudioElementPrototype]";
}
return HTMLMediaElement.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLAudioElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLAudioElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLMediaElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLAudioElement,
expose: {
Window: { HTMLAudioElement: HTMLAudioElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLAudioElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLBRElement() {
throw new TypeError("Illegal constructor");
}
HTMLBRElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLBRElement.prototype.constructor = HTMLBRElement;
HTMLBRElement.prototype.toString = function () {
if (this === HTMLBRElement.prototype) {
return "[object HTMLBRElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLBRElement.prototype, "clear", {
get() {
const value = this.getAttribute("clear");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("clear", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLBRElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLBRElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLBRElement,
expose: {
Window: { HTMLBRElement: HTMLBRElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLBRElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLBaseElement() {
throw new TypeError("Illegal constructor");
}
HTMLBaseElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLBaseElement.prototype.constructor = HTMLBaseElement;
HTMLBaseElement.prototype.toString = function () {
if (this === HTMLBaseElement.prototype) {
return "[object HTMLBaseElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLBaseElement.prototype, "href", {
get() {
return this[impl].href;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].href = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBaseElement.prototype, "target", {
get() {
const value = this.getAttribute("target");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("target", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLBaseElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLBaseElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLBaseElement,
expose: {
Window: { HTMLBaseElement: HTMLBaseElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLBaseElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const WindowEventHandlers = require("./WindowEventHandlers.js");
function HTMLBodyElement() {
throw new TypeError("Illegal constructor");
}
HTMLBodyElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLBodyElement.prototype.constructor = HTMLBodyElement;
mixin(HTMLBodyElement.prototype, WindowEventHandlers.interface.prototype);
WindowEventHandlers.mixedInto.push(HTMLBodyElement);
HTMLBodyElement.prototype.toString = function () {
if (this === HTMLBodyElement.prototype) {
return "[object HTMLBodyElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLBodyElement.prototype, "text", {
get() {
const value = this.getAttribute("text");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("text", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBodyElement.prototype, "link", {
get() {
const value = this.getAttribute("link");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("link", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBodyElement.prototype, "vLink", {
get() {
const value = this.getAttribute("vLink");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("vLink", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBodyElement.prototype, "aLink", {
get() {
const value = this.getAttribute("aLink");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("aLink", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBodyElement.prototype, "bgColor", {
get() {
const value = this.getAttribute("bgColor");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("bgColor", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBodyElement.prototype, "background", {
get() {
const value = this.getAttribute("background");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("background", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLBodyElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLBodyElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLBodyElement,
expose: {
Window: { HTMLBodyElement: HTMLBodyElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLBodyElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLButtonElement() {
throw new TypeError("Illegal constructor");
}
HTMLButtonElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLButtonElement.prototype.constructor = HTMLButtonElement;
HTMLButtonElement.prototype.toString = function () {
if (this === HTMLButtonElement.prototype) {
return "[object HTMLButtonElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLButtonElement.prototype, "autofocus", {
get() {
return this.hasAttribute("autofocus");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("autofocus", "");
} else {
this.removeAttribute("autofocus");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "disabled", {
get() {
return this.hasAttribute("disabled");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("disabled", "");
} else {
this.removeAttribute("disabled");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "formNoValidate", {
get() {
return this.hasAttribute("formNoValidate");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("formNoValidate", "");
} else {
this.removeAttribute("formNoValidate");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "formTarget", {
get() {
const value = this.getAttribute("formTarget");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("formTarget", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "type", {
get() {
return this[impl].type;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].type = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "value", {
get() {
const value = this.getAttribute("value");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("value", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLButtonElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLButtonElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLButtonElement,
expose: {
Window: { HTMLButtonElement: HTMLButtonElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLButtonElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLCanvasElement() {
throw new TypeError("Illegal constructor");
}
HTMLCanvasElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLCanvasElement.prototype.constructor = HTMLCanvasElement;
HTMLCanvasElement.prototype.getContext = function getContext(contextId) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getContext' on 'HTMLCanvasElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
if (args[1] !== undefined) {
args[1] = conversions["any"](args[1]);
}
return utils.tryWrapperForImpl(this[impl].getContext.apply(this[impl], args));
};
HTMLCanvasElement.prototype.probablySupportsContext = function probablySupportsContext(contextId) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'probablySupportsContext' on 'HTMLCanvasElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
if (args[1] !== undefined) {
args[1] = conversions["any"](args[1]);
}
return this[impl].probablySupportsContext.apply(this[impl], args);
};
HTMLCanvasElement.prototype.setContext = function setContext(context) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'setContext' on 'HTMLCanvasElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].setContext.apply(this[impl], args);
};
HTMLCanvasElement.prototype.toDataURL = function toDataURL() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
}
if (args[1] !== undefined) {
args[1] = conversions["any"](args[1]);
}
return this[impl].toDataURL.apply(this[impl], args);
};
HTMLCanvasElement.prototype.toBlob = function toBlob(callback) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'toBlob' on 'HTMLCanvasElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[1] !== undefined) {
args[1] = conversions["DOMString"](args[1]);
}
if (args[2] !== undefined) {
args[2] = conversions["any"](args[2]);
}
return this[impl].toBlob.apply(this[impl], args);
};
HTMLCanvasElement.prototype.toString = function () {
if (this === HTMLCanvasElement.prototype) {
return "[object HTMLCanvasElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLCanvasElement.prototype, "width", {
get() {
return this[impl].width;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].width = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLCanvasElement.prototype, "height", {
get() {
return this[impl].height;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].height = V;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLCanvasElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLCanvasElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLCanvasElement,
expose: {
Window: { HTMLCanvasElement: HTMLCanvasElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLCanvasElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDListElement() {
throw new TypeError("Illegal constructor");
}
HTMLDListElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDListElement.prototype.constructor = HTMLDListElement;
HTMLDListElement.prototype.toString = function () {
if (this === HTMLDListElement.prototype) {
return "[object HTMLDListElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLDListElement.prototype, "compact", {
get() {
return this.hasAttribute("compact");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("compact", "");
} else {
this.removeAttribute("compact");
}
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDListElement,
expose: {
Window: { HTMLDListElement: HTMLDListElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDListElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDataElement() {
throw new TypeError("Illegal constructor");
}
HTMLDataElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDataElement.prototype.constructor = HTMLDataElement;
HTMLDataElement.prototype.toString = function () {
if (this === HTMLDataElement.prototype) {
return "[object HTMLDataElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLDataElement.prototype, "value", {
get() {
const value = this.getAttribute("value");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("value", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDataElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDataElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDataElement,
expose: {
Window: { HTMLDataElement: HTMLDataElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDataElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDataListElement() {
throw new TypeError("Illegal constructor");
}
HTMLDataListElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDataListElement.prototype.constructor = HTMLDataListElement;
HTMLDataListElement.prototype.toString = function () {
if (this === HTMLDataListElement.prototype) {
return "[object HTMLDataListElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDataListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDataListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDataListElement,
expose: {
Window: { HTMLDataListElement: HTMLDataListElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDataListElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDialogElement() {
throw new TypeError("Illegal constructor");
}
HTMLDialogElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDialogElement.prototype.constructor = HTMLDialogElement;
HTMLDialogElement.prototype.toString = function () {
if (this === HTMLDialogElement.prototype) {
return "[object HTMLDialogElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLDialogElement.prototype, "open", {
get() {
return this.hasAttribute("open");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("open", "");
} else {
this.removeAttribute("open");
}
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDialogElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDialogElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDialogElement,
expose: {
Window: { HTMLDialogElement: HTMLDialogElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDialogElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDirectoryElement() {
throw new TypeError("Illegal constructor");
}
HTMLDirectoryElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDirectoryElement.prototype.constructor = HTMLDirectoryElement;
HTMLDirectoryElement.prototype.toString = function () {
if (this === HTMLDirectoryElement.prototype) {
return "[object HTMLDirectoryElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLDirectoryElement.prototype, "compact", {
get() {
return this.hasAttribute("compact");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("compact", "");
} else {
this.removeAttribute("compact");
}
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDirectoryElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDirectoryElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDirectoryElement,
expose: {
Window: { HTMLDirectoryElement: HTMLDirectoryElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDirectoryElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDivElement() {
throw new TypeError("Illegal constructor");
}
HTMLDivElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDivElement.prototype.constructor = HTMLDivElement;
HTMLDivElement.prototype.toString = function () {
if (this === HTMLDivElement.prototype) {
return "[object HTMLDivElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLDivElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDivElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDivElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDivElement,
expose: {
Window: { HTMLDivElement: HTMLDivElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDivElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Element = require("./Element.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const ElementCSSInlineStyle = require("./ElementCSSInlineStyle.js");
const GlobalEventHandlers = require("./GlobalEventHandlers.js");
const ElementContentEditable = require("./ElementContentEditable.js");
function HTMLElement() {
throw new TypeError("Illegal constructor");
}
HTMLElement.prototype = Object.create(Element.interface.prototype);
HTMLElement.prototype.constructor = HTMLElement;
mixin(HTMLElement.prototype, ElementCSSInlineStyle.interface.prototype);
ElementCSSInlineStyle.mixedInto.push(HTMLElement);
mixin(HTMLElement.prototype, GlobalEventHandlers.interface.prototype);
GlobalEventHandlers.mixedInto.push(HTMLElement);
mixin(HTMLElement.prototype, ElementContentEditable.interface.prototype);
ElementContentEditable.mixedInto.push(HTMLElement);
HTMLElement.prototype.click = function click() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].click.apply(this[impl], args);
};
HTMLElement.prototype.focus = function focus() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].focus.apply(this[impl], args);
};
HTMLElement.prototype.blur = function blur() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].blur.apply(this[impl], args);
};
HTMLElement.prototype.toString = function () {
if (this === HTMLElement.prototype) {
return "[object HTMLElementPrototype]";
}
return Element.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLElement.prototype, "title", {
get() {
const value = this.getAttribute("title");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("title", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "lang", {
get() {
const value = this.getAttribute("lang");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("lang", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "dir", {
get() {
const value = this.getAttribute("dir");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("dir", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "hidden", {
get() {
return this.hasAttribute("hidden");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("hidden", "");
} else {
this.removeAttribute("hidden");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "tabIndex", {
get() {
return this[impl].tabIndex;
},
set(V) {
V = conversions["long"](V);
this[impl].tabIndex = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "accessKey", {
get() {
const value = this.getAttribute("accessKey");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("accessKey", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "offsetParent", {
get() {
return utils.tryWrapperForImpl(this[impl].offsetParent);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "offsetTop", {
get() {
return this[impl].offsetTop;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "offsetLeft", {
get() {
return this[impl].offsetLeft;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "offsetWidth", {
get() {
return this[impl].offsetWidth;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "offsetHeight", {
get() {
return this[impl].offsetHeight;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Element._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLElement,
expose: {
Window: { HTMLElement: HTMLElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLEmbedElement() {
throw new TypeError("Illegal constructor");
}
HTMLEmbedElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLEmbedElement.prototype.constructor = HTMLEmbedElement;
HTMLEmbedElement.prototype.toString = function () {
if (this === HTMLEmbedElement.prototype) {
return "[object HTMLEmbedElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLEmbedElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLEmbedElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLEmbedElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLEmbedElement.prototype, "height", {
get() {
const value = this.getAttribute("height");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("height", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLEmbedElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLEmbedElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLEmbedElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLEmbedElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLEmbedElement,
expose: {
Window: { HTMLEmbedElement: HTMLEmbedElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLEmbedElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLFieldSetElement() {
throw new TypeError("Illegal constructor");
}
HTMLFieldSetElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLFieldSetElement.prototype.constructor = HTMLFieldSetElement;
HTMLFieldSetElement.prototype.toString = function () {
if (this === HTMLFieldSetElement.prototype) {
return "[object HTMLFieldSetElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLFieldSetElement.prototype, "disabled", {
get() {
return this.hasAttribute("disabled");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("disabled", "");
} else {
this.removeAttribute("disabled");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFieldSetElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFieldSetElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLFieldSetElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLFieldSetElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLFieldSetElement,
expose: {
Window: { HTMLFieldSetElement: HTMLFieldSetElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLFieldSetElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLFontElement() {
throw new TypeError("Illegal constructor");
}
HTMLFontElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLFontElement.prototype.constructor = HTMLFontElement;
HTMLFontElement.prototype.toString = function () {
if (this === HTMLFontElement.prototype) {
return "[object HTMLFontElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLFontElement.prototype, "color", {
get() {
const value = this.getAttribute("color");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("color", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFontElement.prototype, "face", {
get() {
const value = this.getAttribute("face");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("face", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFontElement.prototype, "size", {
get() {
const value = this.getAttribute("size");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("size", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLFontElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLFontElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLFontElement,
expose: {
Window: { HTMLFontElement: HTMLFontElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLFontElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLFormElement() {
throw new TypeError("Illegal constructor");
}
HTMLFormElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLFormElement.prototype.constructor = HTMLFormElement;
HTMLFormElement.prototype.submit = function submit() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].submit.apply(this[impl], args);
};
HTMLFormElement.prototype.reset = function reset() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].reset.apply(this[impl], args);
};
HTMLFormElement.prototype.toString = function () {
if (this === HTMLFormElement.prototype) {
return "[object HTMLFormElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLFormElement.prototype, "acceptCharset", {
get() {
const value = this.getAttribute("accept-charset");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("accept-charset", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "action", {
get() {
return this[impl].action;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].action = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "enctype", {
get() {
return this[impl].enctype;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].enctype = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "method", {
get() {
return this[impl].method;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].method = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "noValidate", {
get() {
return this.hasAttribute("noValidate");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("noValidate", "");
} else {
this.removeAttribute("noValidate");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "target", {
get() {
const value = this.getAttribute("target");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("target", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "elements", {
get() {
return utils.tryWrapperForImpl(this[impl].elements);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "length", {
get() {
return this[impl].length;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLFormElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLFormElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLFormElement,
expose: {
Window: { HTMLFormElement: HTMLFormElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLFormElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLFrameElement() {
throw new TypeError("Illegal constructor");
}
HTMLFrameElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLFrameElement.prototype.constructor = HTMLFrameElement;
HTMLFrameElement.prototype.toString = function () {
if (this === HTMLFrameElement.prototype) {
return "[object HTMLFrameElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLFrameElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "scrolling", {
get() {
const value = this.getAttribute("scrolling");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("scrolling", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "frameBorder", {
get() {
const value = this.getAttribute("frameBorder");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("frameBorder", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "longDesc", {
get() {
return this[impl].longDesc;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].longDesc = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "noResize", {
get() {
return this.hasAttribute("noResize");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("noResize", "");
} else {
this.removeAttribute("noResize");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "contentDocument", {
get() {
return utils.tryWrapperForImpl(this[impl].contentDocument);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "contentWindow", {
get() {
return utils.tryWrapperForImpl(this[impl].contentWindow);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "marginHeight", {
get() {
const value = this.getAttribute("marginHeight");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("marginHeight", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "marginWidth", {
get() {
const value = this.getAttribute("marginWidth");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("marginWidth", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLFrameElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLFrameElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLFrameElement,
expose: {
Window: { HTMLFrameElement: HTMLFrameElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLFrameElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const WindowEventHandlers = require("./WindowEventHandlers.js");
function HTMLFrameSetElement() {
throw new TypeError("Illegal constructor");
}
HTMLFrameSetElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLFrameSetElement.prototype.constructor = HTMLFrameSetElement;
mixin(HTMLFrameSetElement.prototype, WindowEventHandlers.interface.prototype);
WindowEventHandlers.mixedInto.push(HTMLFrameSetElement);
HTMLFrameSetElement.prototype.toString = function () {
if (this === HTMLFrameSetElement.prototype) {
return "[object HTMLFrameSetElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLFrameSetElement.prototype, "cols", {
get() {
const value = this.getAttribute("cols");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("cols", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameSetElement.prototype, "rows", {
get() {
const value = this.getAttribute("rows");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("rows", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLFrameSetElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLFrameSetElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLFrameSetElement,
expose: {
Window: { HTMLFrameSetElement: HTMLFrameSetElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLFrameSetElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLHRElement() {
throw new TypeError("Illegal constructor");
}
HTMLHRElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLHRElement.prototype.constructor = HTMLHRElement;
HTMLHRElement.prototype.toString = function () {
if (this === HTMLHRElement.prototype) {
return "[object HTMLHRElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLHRElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHRElement.prototype, "color", {
get() {
const value = this.getAttribute("color");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("color", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHRElement.prototype, "noShade", {
get() {
return this.hasAttribute("noShade");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("noShade", "");
} else {
this.removeAttribute("noShade");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHRElement.prototype, "size", {
get() {
const value = this.getAttribute("size");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("size", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHRElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLHRElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLHRElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLHRElement,
expose: {
Window: { HTMLHRElement: HTMLHRElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLHRElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLHeadElement() {
throw new TypeError("Illegal constructor");
}
HTMLHeadElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLHeadElement.prototype.constructor = HTMLHeadElement;
HTMLHeadElement.prototype.toString = function () {
if (this === HTMLHeadElement.prototype) {
return "[object HTMLHeadElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLHeadElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLHeadElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLHeadElement,
expose: {
Window: { HTMLHeadElement: HTMLHeadElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLHeadElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLHeadingElement() {
throw new TypeError("Illegal constructor");
}
HTMLHeadingElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLHeadingElement.prototype.constructor = HTMLHeadingElement;
HTMLHeadingElement.prototype.toString = function () {
if (this === HTMLHeadingElement.prototype) {
return "[object HTMLHeadingElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLHeadingElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLHeadingElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLHeadingElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLHeadingElement,
expose: {
Window: { HTMLHeadingElement: HTMLHeadingElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLHeadingElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLHtmlElement() {
throw new TypeError("Illegal constructor");
}
HTMLHtmlElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLHtmlElement.prototype.constructor = HTMLHtmlElement;
HTMLHtmlElement.prototype.toString = function () {
if (this === HTMLHtmlElement.prototype) {
return "[object HTMLHtmlElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLHtmlElement.prototype, "version", {
get() {
const value = this.getAttribute("version");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("version", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLHtmlElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLHtmlElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLHtmlElement,
expose: {
Window: { HTMLHtmlElement: HTMLHtmlElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLHtmlElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function HTMLHyperlinkElementUtils() {
throw new TypeError("Illegal constructor");
}
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "href", {
get() {
return this[impl].href;
},
set(V) {
V = conversions["USVString"](V);
this[impl].href = V;
},
enumerable: true,
configurable: true
});
HTMLHyperlinkElementUtils.prototype.toString = function () {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl].href;;
};
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "origin", {
get() {
return this[impl].origin;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "protocol", {
get() {
return this[impl].protocol;
},
set(V) {
V = conversions["USVString"](V);
this[impl].protocol = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "username", {
get() {
return this[impl].username;
},
set(V) {
V = conversions["USVString"](V);
this[impl].username = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "password", {
get() {
return this[impl].password;
},
set(V) {
V = conversions["USVString"](V);
this[impl].password = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "host", {
get() {
return this[impl].host;
},
set(V) {
V = conversions["USVString"](V);
this[impl].host = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "hostname", {
get() {
return this[impl].hostname;
},
set(V) {
V = conversions["USVString"](V);
this[impl].hostname = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "port", {
get() {
return this[impl].port;
},
set(V) {
V = conversions["USVString"](V);
this[impl].port = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "pathname", {
get() {
return this[impl].pathname;
},
set(V) {
V = conversions["USVString"](V);
this[impl].pathname = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "search", {
get() {
return this[impl].search;
},
set(V) {
V = conversions["USVString"](V);
this[impl].search = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "hash", {
get() {
return this[impl].hash;
},
set(V) {
V = conversions["USVString"](V);
this[impl].hash = V;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLHyperlinkElementUtils.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLHyperlinkElementUtils.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLHyperlinkElementUtils,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLHyperlinkElementUtils-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLIFrameElement() {
throw new TypeError("Illegal constructor");
}
HTMLIFrameElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLIFrameElement.prototype.constructor = HTMLIFrameElement;
HTMLIFrameElement.prototype.getSVGDocument = function getSVGDocument() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].getSVGDocument.apply(this[impl], args));
};
HTMLIFrameElement.prototype.toString = function () {
if (this === HTMLIFrameElement.prototype) {
return "[object HTMLIFrameElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLIFrameElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "srcdoc", {
get() {
const value = this.getAttribute("srcdoc");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("srcdoc", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "seamless", {
get() {
return this[impl].seamless;
},
set(V) {
V = conversions["boolean"](V);
this[impl].seamless = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "allowFullscreen", {
get() {
return this.hasAttribute("allowFullscreen");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("allowFullscreen", "");
} else {
this.removeAttribute("allowFullscreen");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "height", {
get() {
const value = this.getAttribute("height");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("height", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "contentDocument", {
get() {
return utils.tryWrapperForImpl(this[impl].contentDocument);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "contentWindow", {
get() {
return utils.tryWrapperForImpl(this[impl].contentWindow);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "scrolling", {
get() {
const value = this.getAttribute("scrolling");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("scrolling", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "frameBorder", {
get() {
const value = this.getAttribute("frameBorder");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("frameBorder", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "longDesc", {
get() {
return this[impl].longDesc;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].longDesc = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "marginHeight", {
get() {
const value = this.getAttribute("marginHeight");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("marginHeight", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "marginWidth", {
get() {
const value = this.getAttribute("marginWidth");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("marginWidth", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLIFrameElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLIFrameElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLIFrameElement,
expose: {
Window: { HTMLIFrameElement: HTMLIFrameElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLIFrameElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLImageElement() {
throw new TypeError("Illegal constructor");
}
HTMLImageElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLImageElement.prototype.constructor = HTMLImageElement;
HTMLImageElement.prototype.toString = function () {
if (this === HTMLImageElement.prototype) {
return "[object HTMLImageElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLImageElement.prototype, "alt", {
get() {
const value = this.getAttribute("alt");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("alt", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "srcset", {
get() {
const value = this.getAttribute("srcset");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("srcset", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "sizes", {
get() {
const value = this.getAttribute("sizes");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("sizes", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "crossOrigin", {
get() {
const value = this.getAttribute("crossOrigin");
return value === null ? "" : value;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["DOMString"](V);
}
this.setAttribute("crossOrigin", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "useMap", {
get() {
const value = this.getAttribute("useMap");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("useMap", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "isMap", {
get() {
return this.hasAttribute("isMap");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("isMap", "");
} else {
this.removeAttribute("isMap");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "width", {
get() {
return this[impl].width;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].width = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "height", {
get() {
return this[impl].height;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].height = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "naturalWidth", {
get() {
return this[impl].naturalWidth;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "naturalHeight", {
get() {
return this[impl].naturalHeight;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "complete", {
get() {
return this[impl].complete;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "currentSrc", {
get() {
return this[impl].currentSrc;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "lowsrc", {
get() {
const value = this.getAttribute("lowsrc");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("lowsrc", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "hspace", {
get() {
const value = parseInt(this.getAttribute("hspace"));
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["long"](V);
this.setAttribute("hspace", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "vspace", {
get() {
const value = parseInt(this.getAttribute("vspace"));
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["long"](V);
this.setAttribute("vspace", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "longDesc", {
get() {
const value = this.getAttribute("longDesc");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("longDesc", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "border", {
get() {
const value = this.getAttribute("border");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("border", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLImageElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLImageElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLImageElement,
expose: {
Window: { HTMLImageElement: HTMLImageElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLImageElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLInputElement() {
throw new TypeError("Illegal constructor");
}
HTMLInputElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLInputElement.prototype.constructor = HTMLInputElement;
HTMLInputElement.prototype.select = function select() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].select.apply(this[impl], args);
};
HTMLInputElement.prototype.setRangeText = function setRangeText(replacement) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'setRangeText' on 'HTMLInputElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 4; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].setRangeText.apply(this[impl], args);
};
HTMLInputElement.prototype.setSelectionRange = function setSelectionRange(start, end) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'setSelectionRange' on 'HTMLInputElement': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
args[1] = conversions["unsigned long"](args[1]);
if (args[2] !== undefined) {
args[2] = conversions["DOMString"](args[2]);
}
return this[impl].setSelectionRange.apply(this[impl], args);
};
HTMLInputElement.prototype.toString = function () {
if (this === HTMLInputElement.prototype) {
return "[object HTMLInputElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLInputElement.prototype, "accept", {
get() {
const value = this.getAttribute("accept");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("accept", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "alt", {
get() {
const value = this.getAttribute("alt");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("alt", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "autocomplete", {
get() {
const value = this.getAttribute("autocomplete");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("autocomplete", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "autofocus", {
get() {
return this.hasAttribute("autofocus");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("autofocus", "");
} else {
this.removeAttribute("autofocus");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "defaultChecked", {
get() {
return this.hasAttribute("checked");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("checked", "");
} else {
this.removeAttribute("checked");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "checked", {
get() {
return this[impl].checked;
},
set(V) {
V = conversions["boolean"](V);
this[impl].checked = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "dirName", {
get() {
const value = this.getAttribute("dirName");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("dirName", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "disabled", {
get() {
return this.hasAttribute("disabled");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("disabled", "");
} else {
this.removeAttribute("disabled");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "files", {
get() {
return utils.tryWrapperForImpl(this[impl].files);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "formNoValidate", {
get() {
return this.hasAttribute("formNoValidate");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("formNoValidate", "");
} else {
this.removeAttribute("formNoValidate");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "formTarget", {
get() {
const value = this.getAttribute("formTarget");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("formTarget", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "inputMode", {
get() {
const value = this.getAttribute("inputMode");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("inputMode", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "max", {
get() {
const value = this.getAttribute("max");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("max", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "maxLength", {
get() {
return this[impl].maxLength;
},
set(V) {
V = conversions["long"](V);
this[impl].maxLength = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "min", {
get() {
const value = this.getAttribute("min");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("min", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "minLength", {
get() {
return this[impl].minLength;
},
set(V) {
V = conversions["long"](V);
this[impl].minLength = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "multiple", {
get() {
return this.hasAttribute("multiple");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("multiple", "");
} else {
this.removeAttribute("multiple");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "pattern", {
get() {
const value = this.getAttribute("pattern");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("pattern", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "placeholder", {
get() {
const value = this.getAttribute("placeholder");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("placeholder", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "readOnly", {
get() {
return this.hasAttribute("readOnly");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("readOnly", "");
} else {
this.removeAttribute("readOnly");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "required", {
get() {
return this.hasAttribute("required");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("required", "");
} else {
this.removeAttribute("required");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "size", {
get() {
return this[impl].size;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].size = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "src", {
get() {
const value = this.getAttribute("src");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("src", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "step", {
get() {
const value = this.getAttribute("step");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("step", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "type", {
get() {
return this[impl].type;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].type = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "defaultValue", {
get() {
const value = this.getAttribute("value");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("value", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "value", {
get() {
return this[impl].value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].value = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "selectionStart", {
get() {
return this[impl].selectionStart;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["unsigned long"](V);
}
this[impl].selectionStart = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "selectionEnd", {
get() {
return this[impl].selectionEnd;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["unsigned long"](V);
}
this[impl].selectionEnd = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "selectionDirection", {
get() {
return this[impl].selectionDirection;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["DOMString"](V);
}
this[impl].selectionDirection = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "useMap", {
get() {
const value = this.getAttribute("useMap");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("useMap", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLInputElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLInputElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLInputElement,
expose: {
Window: { HTMLInputElement: HTMLInputElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLInputElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLLIElement() {
throw new TypeError("Illegal constructor");
}
HTMLLIElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLLIElement.prototype.constructor = HTMLLIElement;
HTMLLIElement.prototype.toString = function () {
if (this === HTMLLIElement.prototype) {
return "[object HTMLLIElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLLIElement.prototype, "value", {
get() {
const value = parseInt(this.getAttribute("value"));
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["long"](V);
this.setAttribute("value", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLLIElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLLIElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLLIElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLLIElement,
expose: {
Window: { HTMLLIElement: HTMLLIElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLLIElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLLabelElement() {
throw new TypeError("Illegal constructor");
}
HTMLLabelElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLLabelElement.prototype.constructor = HTMLLabelElement;
HTMLLabelElement.prototype.toString = function () {
if (this === HTMLLabelElement.prototype) {
return "[object HTMLLabelElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLLabelElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLLabelElement.prototype, "htmlFor", {
get() {
const value = this.getAttribute("for");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("for", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLLabelElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLLabelElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLLabelElement,
expose: {
Window: { HTMLLabelElement: HTMLLabelElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLLabelElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLLegendElement() {
throw new TypeError("Illegal constructor");
}
HTMLLegendElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLLegendElement.prototype.constructor = HTMLLegendElement;
HTMLLegendElement.prototype.toString = function () {
if (this === HTMLLegendElement.prototype) {
return "[object HTMLLegendElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLLegendElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLLegendElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLLegendElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLLegendElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLLegendElement,
expose: {
Window: { HTMLLegendElement: HTMLLegendElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLLegendElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const LinkStyle = require("./LinkStyle.js");
function HTMLLinkElement() {
throw new TypeError("Illegal constructor");
}
HTMLLinkElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLLinkElement.prototype.constructor = HTMLLinkElement;
mixin(HTMLLinkElement.prototype, LinkStyle.interface.prototype);
LinkStyle.mixedInto.push(HTMLLinkElement);
HTMLLinkElement.prototype.toString = function () {
if (this === HTMLLinkElement.prototype) {
return "[object HTMLLinkElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLLinkElement.prototype, "href", {
get() {
return this[impl].href;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].href = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLLinkElement.prototype, "crossOrigin", {
get() {
const value = this.getAttribute("crossOrigin");
return value === null ? "" : value;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["DOMString"](V);
}
this.setAttribute("crossOrigin", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLLinkElement.prototype, "rel", {
get() {
const value = this.getAttribute("rel");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("rel", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLLinkElement.prototype, "media", {
get() {
const value = this.getAttribute("media");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("media", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLLinkElement.prototype, "hreflang", {
get() {
const value = this.getAttribute("hreflang");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("hreflang", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLLinkElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLLinkElement.prototype, "charset", {
get() {
const value = this.getAttribute("charset");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("charset", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLLinkElement.prototype, "rev", {
get() {
const value = this.getAttribute("rev");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("rev", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLLinkElement.prototype, "target", {
get() {
const value = this.getAttribute("target");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("target", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLLinkElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLLinkElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLLinkElement,
expose: {
Window: { HTMLLinkElement: HTMLLinkElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLLinkElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLMapElement() {
throw new TypeError("Illegal constructor");
}
HTMLMapElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLMapElement.prototype.constructor = HTMLMapElement;
HTMLMapElement.prototype.toString = function () {
if (this === HTMLMapElement.prototype) {
return "[object HTMLMapElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLMapElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMapElement.prototype, "areas", {
get() {
return utils.tryWrapperForImpl(this[impl].areas);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLMapElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLMapElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLMapElement,
expose: {
Window: { HTMLMapElement: HTMLMapElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLMapElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLMediaElement() {
throw new TypeError("Illegal constructor");
}
HTMLMediaElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLMediaElement.prototype.constructor = HTMLMediaElement;
HTMLMediaElement.prototype.load = function load() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].load.apply(this[impl], args);
};
HTMLMediaElement.prototype.canPlayType = function canPlayType(type) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'canPlayType' on 'HTMLMediaElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].canPlayType.apply(this[impl], args));
};
HTMLMediaElement.prototype.play = function play() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].play.apply(this[impl], args);
};
HTMLMediaElement.prototype.pause = function pause() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].pause.apply(this[impl], args);
};
HTMLMediaElement.prototype.addTextTrack = function addTextTrack(kind) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'addTextTrack' on 'HTMLMediaElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[1] !== undefined) {
args[1] = conversions["DOMString"](args[1]);
} else {
args[1] = "";
}
if (args[2] !== undefined) {
args[2] = conversions["DOMString"](args[2]);
} else {
args[2] = "";
}
return utils.tryWrapperForImpl(this[impl].addTextTrack.apply(this[impl], args));
};
HTMLMediaElement.prototype.toString = function () {
if (this === HTMLMediaElement.prototype) {
return "[object HTMLMediaElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLMediaElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "currentSrc", {
get() {
return this[impl].currentSrc;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "crossOrigin", {
get() {
const value = this.getAttribute("crossOrigin");
return value === null ? "" : value;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["DOMString"](V);
}
this.setAttribute("crossOrigin", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement, "NETWORK_EMPTY", {
value: 0,
enumerable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "NETWORK_EMPTY", {
value: 0,
enumerable: true
});
Object.defineProperty(HTMLMediaElement, "NETWORK_IDLE", {
value: 1,
enumerable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "NETWORK_IDLE", {
value: 1,
enumerable: true
});
Object.defineProperty(HTMLMediaElement, "NETWORK_LOADING", {
value: 2,
enumerable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "NETWORK_LOADING", {
value: 2,
enumerable: true
});
Object.defineProperty(HTMLMediaElement, "NETWORK_NO_SOURCE", {
value: 3,
enumerable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "NETWORK_NO_SOURCE", {
value: 3,
enumerable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "networkState", {
get() {
return this[impl].networkState;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "preload", {
get() {
const value = this.getAttribute("preload");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("preload", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "buffered", {
get() {
return utils.tryWrapperForImpl(this[impl].buffered);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement, "HAVE_NOTHING", {
value: 0,
enumerable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "HAVE_NOTHING", {
value: 0,
enumerable: true
});
Object.defineProperty(HTMLMediaElement, "HAVE_METADATA", {
value: 1,
enumerable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "HAVE_METADATA", {
value: 1,
enumerable: true
});
Object.defineProperty(HTMLMediaElement, "HAVE_CURRENT_DATA", {
value: 2,
enumerable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "HAVE_CURRENT_DATA", {
value: 2,
enumerable: true
});
Object.defineProperty(HTMLMediaElement, "HAVE_FUTURE_DATA", {
value: 3,
enumerable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "HAVE_FUTURE_DATA", {
value: 3,
enumerable: true
});
Object.defineProperty(HTMLMediaElement, "HAVE_ENOUGH_DATA", {
value: 4,
enumerable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "HAVE_ENOUGH_DATA", {
value: 4,
enumerable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "readyState", {
get() {
return this[impl].readyState;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "seeking", {
get() {
return this[impl].seeking;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "currentTime", {
get() {
return this[impl].currentTime;
},
set(V) {
V = conversions["double"](V);
this[impl].currentTime = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "duration", {
get() {
return this[impl].duration;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "paused", {
get() {
return this[impl].paused;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "defaultPlaybackRate", {
get() {
return this[impl].defaultPlaybackRate;
},
set(V) {
V = conversions["double"](V);
this[impl].defaultPlaybackRate = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "playbackRate", {
get() {
return this[impl].playbackRate;
},
set(V) {
V = conversions["double"](V);
this[impl].playbackRate = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "played", {
get() {
return utils.tryWrapperForImpl(this[impl].played);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "seekable", {
get() {
return utils.tryWrapperForImpl(this[impl].seekable);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "ended", {
get() {
return this[impl].ended;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "autoplay", {
get() {
return this.hasAttribute("autoplay");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("autoplay", "");
} else {
this.removeAttribute("autoplay");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "loop", {
get() {
return this.hasAttribute("loop");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("loop", "");
} else {
this.removeAttribute("loop");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "controls", {
get() {
return this.hasAttribute("controls");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("controls", "");
} else {
this.removeAttribute("controls");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "volume", {
get() {
return this[impl].volume;
},
set(V) {
V = conversions["double"](V);
this[impl].volume = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "muted", {
get() {
return this[impl].muted;
},
set(V) {
V = conversions["boolean"](V);
this[impl].muted = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "defaultMuted", {
get() {
return this.hasAttribute("muted");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("muted", "");
} else {
this.removeAttribute("muted");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "audioTracks", {
get() {
return utils.tryWrapperForImpl(this[impl].audioTracks);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "videoTracks", {
get() {
return utils.tryWrapperForImpl(this[impl].videoTracks);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMediaElement.prototype, "textTracks", {
get() {
return utils.tryWrapperForImpl(this[impl].textTracks);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLMediaElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLMediaElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLMediaElement,
expose: {
Window: { HTMLMediaElement: HTMLMediaElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLMediaElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLMenuElement() {
throw new TypeError("Illegal constructor");
}
HTMLMenuElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLMenuElement.prototype.constructor = HTMLMenuElement;
HTMLMenuElement.prototype.toString = function () {
if (this === HTMLMenuElement.prototype) {
return "[object HTMLMenuElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLMenuElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMenuElement.prototype, "label", {
get() {
const value = this.getAttribute("label");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("label", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMenuElement.prototype, "compact", {
get() {
return this.hasAttribute("compact");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("compact", "");
} else {
this.removeAttribute("compact");
}
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLMenuElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLMenuElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLMenuElement,
expose: {
Window: { HTMLMenuElement: HTMLMenuElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLMenuElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLMetaElement() {
throw new TypeError("Illegal constructor");
}
HTMLMetaElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLMetaElement.prototype.constructor = HTMLMetaElement;
HTMLMetaElement.prototype.toString = function () {
if (this === HTMLMetaElement.prototype) {
return "[object HTMLMetaElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLMetaElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMetaElement.prototype, "httpEquiv", {
get() {
const value = this.getAttribute("http-equiv");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("http-equiv", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMetaElement.prototype, "content", {
get() {
const value = this.getAttribute("content");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("content", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLMetaElement.prototype, "scheme", {
get() {
const value = this.getAttribute("scheme");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("scheme", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLMetaElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLMetaElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLMetaElement,
expose: {
Window: { HTMLMetaElement: HTMLMetaElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLMetaElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLMeterElement() {
throw new TypeError("Illegal constructor");
}
HTMLMeterElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLMeterElement.prototype.constructor = HTMLMeterElement;
HTMLMeterElement.prototype.toString = function () {
if (this === HTMLMeterElement.prototype) {
return "[object HTMLMeterElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLMeterElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLMeterElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLMeterElement,
expose: {
Window: { HTMLMeterElement: HTMLMeterElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLMeterElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLModElement() {
throw new TypeError("Illegal constructor");
}
HTMLModElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLModElement.prototype.constructor = HTMLModElement;
HTMLModElement.prototype.toString = function () {
if (this === HTMLModElement.prototype) {
return "[object HTMLModElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLModElement.prototype, "cite", {
get() {
const value = this.getAttribute("cite");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("cite", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLModElement.prototype, "dateTime", {
get() {
const value = this.getAttribute("dateTime");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("dateTime", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLModElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLModElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLModElement,
expose: {
Window: { HTMLModElement: HTMLModElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLModElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLOListElement() {
throw new TypeError("Illegal constructor");
}
HTMLOListElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLOListElement.prototype.constructor = HTMLOListElement;
HTMLOListElement.prototype.toString = function () {
if (this === HTMLOListElement.prototype) {
return "[object HTMLOListElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLOListElement.prototype, "reversed", {
get() {
return this.hasAttribute("reversed");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("reversed", "");
} else {
this.removeAttribute("reversed");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLOListElement.prototype, "start", {
get() {
const value = parseInt(this.getAttribute("start"));
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["long"](V);
this.setAttribute("start", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLOListElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLOListElement.prototype, "compact", {
get() {
return this.hasAttribute("compact");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("compact", "");
} else {
this.removeAttribute("compact");
}
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLOListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLOListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLOListElement,
expose: {
Window: { HTMLOListElement: HTMLOListElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLOListElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLObjectElement() {
throw new TypeError("Illegal constructor");
}
HTMLObjectElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLObjectElement.prototype.constructor = HTMLObjectElement;
HTMLObjectElement.prototype.toString = function () {
if (this === HTMLObjectElement.prototype) {
return "[object HTMLObjectElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLObjectElement.prototype, "data", {
get() {
return this[impl].data;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].data = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "useMap", {
get() {
const value = this.getAttribute("useMap");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("useMap", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "height", {
get() {
const value = this.getAttribute("height");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("height", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "contentDocument", {
get() {
return utils.tryWrapperForImpl(this[impl].contentDocument);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "archive", {
get() {
const value = this.getAttribute("archive");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("archive", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "code", {
get() {
const value = this.getAttribute("code");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("code", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "declare", {
get() {
return this.hasAttribute("declare");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("declare", "");
} else {
this.removeAttribute("declare");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "hspace", {
get() {
const value = parseInt(this.getAttribute("hspace"));
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["unsigned long"](V);
V = V > 2147483647 ? 0 : V;
this.setAttribute("hspace", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "standby", {
get() {
const value = this.getAttribute("standby");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("standby", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "vspace", {
get() {
const value = parseInt(this.getAttribute("vspace"));
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["unsigned long"](V);
V = V > 2147483647 ? 0 : V;
this.setAttribute("vspace", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "codeBase", {
get() {
return this[impl].codeBase;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].codeBase = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "codeType", {
get() {
const value = this.getAttribute("codeType");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("codeType", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLObjectElement.prototype, "border", {
get() {
const value = this.getAttribute("border");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("border", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLObjectElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLObjectElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLObjectElement,
expose: {
Window: { HTMLObjectElement: HTMLObjectElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLObjectElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLOptGroupElement() {
throw new TypeError("Illegal constructor");
}
HTMLOptGroupElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLOptGroupElement.prototype.constructor = HTMLOptGroupElement;
HTMLOptGroupElement.prototype.toString = function () {
if (this === HTMLOptGroupElement.prototype) {
return "[object HTMLOptGroupElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLOptGroupElement.prototype, "disabled", {
get() {
return this.hasAttribute("disabled");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("disabled", "");
} else {
this.removeAttribute("disabled");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLOptGroupElement.prototype, "label", {
get() {
const value = this.getAttribute("label");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("label", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLOptGroupElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLOptGroupElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLOptGroupElement,
expose: {
Window: { HTMLOptGroupElement: HTMLOptGroupElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLOptGroupElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLOptionElement() {
throw new TypeError("Illegal constructor");
}
HTMLOptionElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLOptionElement.prototype.constructor = HTMLOptionElement;
HTMLOptionElement.prototype.toString = function () {
if (this === HTMLOptionElement.prototype) {
return "[object HTMLOptionElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLOptionElement.prototype, "disabled", {
get() {
return this.hasAttribute("disabled");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("disabled", "");
} else {
this.removeAttribute("disabled");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLOptionElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLOptionElement.prototype, "label", {
get() {
return this[impl].label;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].label = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLOptionElement.prototype, "defaultSelected", {
get() {
return this.hasAttribute("selected");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("selected", "");
} else {
this.removeAttribute("selected");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLOptionElement.prototype, "selected", {
get() {
return this[impl].selected;
},
set(V) {
V = conversions["boolean"](V);
this[impl].selected = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLOptionElement.prototype, "value", {
get() {
return this[impl].value;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].value = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLOptionElement.prototype, "text", {
get() {
return this[impl].text;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].text = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLOptionElement.prototype, "index", {
get() {
return this[impl].index;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLOptionElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLOptionElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLOptionElement,
expose: {
Window: { HTMLOptionElement: HTMLOptionElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLOptionElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLOutputElement() {
throw new TypeError("Illegal constructor");
}
HTMLOutputElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLOutputElement.prototype.constructor = HTMLOutputElement;
HTMLOutputElement.prototype.toString = function () {
if (this === HTMLOutputElement.prototype) {
return "[object HTMLOutputElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLOutputElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLOutputElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLOutputElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLOutputElement,
expose: {
Window: { HTMLOutputElement: HTMLOutputElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLOutputElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLParagraphElement() {
throw new TypeError("Illegal constructor");
}
HTMLParagraphElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLParagraphElement.prototype.constructor = HTMLParagraphElement;
HTMLParagraphElement.prototype.toString = function () {
if (this === HTMLParagraphElement.prototype) {
return "[object HTMLParagraphElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLParagraphElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLParagraphElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLParagraphElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLParagraphElement,
expose: {
Window: { HTMLParagraphElement: HTMLParagraphElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLParagraphElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLParamElement() {
throw new TypeError("Illegal constructor");
}
HTMLParamElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLParamElement.prototype.constructor = HTMLParamElement;
HTMLParamElement.prototype.toString = function () {
if (this === HTMLParamElement.prototype) {
return "[object HTMLParamElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLParamElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLParamElement.prototype, "value", {
get() {
const value = this.getAttribute("value");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("value", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLParamElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLParamElement.prototype, "valueType", {
get() {
const value = this.getAttribute("valueType");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("valueType", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLParamElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLParamElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLParamElement,
expose: {
Window: { HTMLParamElement: HTMLParamElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLParamElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLPreElement() {
throw new TypeError("Illegal constructor");
}
HTMLPreElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLPreElement.prototype.constructor = HTMLPreElement;
HTMLPreElement.prototype.toString = function () {
if (this === HTMLPreElement.prototype) {
return "[object HTMLPreElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLPreElement.prototype, "width", {
get() {
const value = parseInt(this.getAttribute("width"));
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["long"](V);
this.setAttribute("width", String(V));
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLPreElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLPreElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLPreElement,
expose: {
Window: { HTMLPreElement: HTMLPreElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLPreElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLProgressElement() {
throw new TypeError("Illegal constructor");
}
HTMLProgressElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLProgressElement.prototype.constructor = HTMLProgressElement;
HTMLProgressElement.prototype.toString = function () {
if (this === HTMLProgressElement.prototype) {
return "[object HTMLProgressElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLProgressElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLProgressElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLProgressElement,
expose: {
Window: { HTMLProgressElement: HTMLProgressElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLProgressElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLQuoteElement() {
throw new TypeError("Illegal constructor");
}
HTMLQuoteElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLQuoteElement.prototype.constructor = HTMLQuoteElement;
HTMLQuoteElement.prototype.toString = function () {
if (this === HTMLQuoteElement.prototype) {
return "[object HTMLQuoteElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLQuoteElement.prototype, "cite", {
get() {
const value = this.getAttribute("cite");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("cite", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLQuoteElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLQuoteElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLQuoteElement,
expose: {
Window: { HTMLQuoteElement: HTMLQuoteElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLQuoteElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLScriptElement() {
throw new TypeError("Illegal constructor");
}
HTMLScriptElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLScriptElement.prototype.constructor = HTMLScriptElement;
HTMLScriptElement.prototype.toString = function () {
if (this === HTMLScriptElement.prototype) {
return "[object HTMLScriptElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLScriptElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLScriptElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLScriptElement.prototype, "charset", {
get() {
const value = this.getAttribute("charset");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("charset", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLScriptElement.prototype, "defer", {
get() {
return this.hasAttribute("defer");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("defer", "");
} else {
this.removeAttribute("defer");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLScriptElement.prototype, "crossOrigin", {
get() {
const value = this.getAttribute("crossOrigin");
return value === null ? "" : value;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["DOMString"](V);
}
this.setAttribute("crossOrigin", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLScriptElement.prototype, "text", {
get() {
return this[impl].text;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].text = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLScriptElement.prototype, "nonce", {
get() {
const value = this.getAttribute("nonce");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("nonce", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLScriptElement.prototype, "event", {
get() {
const value = this.getAttribute("event");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("event", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLScriptElement.prototype, "htmlFor", {
get() {
const value = this.getAttribute("for");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("for", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLScriptElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLScriptElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLScriptElement,
expose: {
Window: { HTMLScriptElement: HTMLScriptElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLScriptElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLSelectElement() {
throw new TypeError("Illegal constructor");
}
HTMLSelectElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLSelectElement.prototype.constructor = HTMLSelectElement;
HTMLSelectElement.prototype.add = function add(element) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'add' on 'HTMLSelectElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[1] === null || args[1] === undefined) {
args[1] = null;
} else {
}
return this[impl].add.apply(this[impl], args);
};
HTMLSelectElement.prototype.remove = function remove() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].remove.apply(this[impl], args);
};
HTMLSelectElement.prototype.toString = function () {
if (this === HTMLSelectElement.prototype) {
return "[object HTMLSelectElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLSelectElement.prototype, "autofocus", {
get() {
return this.hasAttribute("autofocus");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("autofocus", "");
} else {
this.removeAttribute("autofocus");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSelectElement.prototype, "disabled", {
get() {
return this.hasAttribute("disabled");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("disabled", "");
} else {
this.removeAttribute("disabled");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSelectElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSelectElement.prototype, "multiple", {
get() {
return this.hasAttribute("multiple");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("multiple", "");
} else {
this.removeAttribute("multiple");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSelectElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSelectElement.prototype, "required", {
get() {
return this.hasAttribute("required");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("required", "");
} else {
this.removeAttribute("required");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSelectElement.prototype, "size", {
get() {
return this[impl].size;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].size = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSelectElement.prototype, "type", {
get() {
return this[impl].type;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSelectElement.prototype, "options", {
get() {
return utils.tryWrapperForImpl(this[impl].options);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSelectElement.prototype, "length", {
get() {
return this[impl].length;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].length = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSelectElement.prototype, "selectedIndex", {
get() {
return this[impl].selectedIndex;
},
set(V) {
V = conversions["long"](V);
this[impl].selectedIndex = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSelectElement.prototype, "value", {
get() {
return this[impl].value;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].value = V;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLSelectElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLSelectElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLSelectElement,
expose: {
Window: { HTMLSelectElement: HTMLSelectElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLSelectElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLSourceElement() {
throw new TypeError("Illegal constructor");
}
HTMLSourceElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLSourceElement.prototype.constructor = HTMLSourceElement;
HTMLSourceElement.prototype.toString = function () {
if (this === HTMLSourceElement.prototype) {
return "[object HTMLSourceElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLSourceElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSourceElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSourceElement.prototype, "srcset", {
get() {
const value = this.getAttribute("srcset");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("srcset", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSourceElement.prototype, "sizes", {
get() {
const value = this.getAttribute("sizes");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("sizes", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLSourceElement.prototype, "media", {
get() {
const value = this.getAttribute("media");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("media", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLSourceElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLSourceElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLSourceElement,
expose: {
Window: { HTMLSourceElement: HTMLSourceElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLSourceElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLSpanElement() {
throw new TypeError("Illegal constructor");
}
HTMLSpanElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLSpanElement.prototype.constructor = HTMLSpanElement;
HTMLSpanElement.prototype.toString = function () {
if (this === HTMLSpanElement.prototype) {
return "[object HTMLSpanElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLSpanElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLSpanElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLSpanElement,
expose: {
Window: { HTMLSpanElement: HTMLSpanElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLSpanElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const LinkStyle = require("./LinkStyle.js");
function HTMLStyleElement() {
throw new TypeError("Illegal constructor");
}
HTMLStyleElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLStyleElement.prototype.constructor = HTMLStyleElement;
mixin(HTMLStyleElement.prototype, LinkStyle.interface.prototype);
LinkStyle.mixedInto.push(HTMLStyleElement);
HTMLStyleElement.prototype.toString = function () {
if (this === HTMLStyleElement.prototype) {
return "[object HTMLStyleElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLStyleElement.prototype, "media", {
get() {
const value = this.getAttribute("media");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("media", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLStyleElement.prototype, "nonce", {
get() {
const value = this.getAttribute("nonce");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("nonce", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLStyleElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLStyleElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLStyleElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLStyleElement,
expose: {
Window: { HTMLStyleElement: HTMLStyleElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLStyleElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLTableCaptionElement() {
throw new TypeError("Illegal constructor");
}
HTMLTableCaptionElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLTableCaptionElement.prototype.constructor = HTMLTableCaptionElement;
HTMLTableCaptionElement.prototype.toString = function () {
if (this === HTMLTableCaptionElement.prototype) {
return "[object HTMLTableCaptionElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTableCaptionElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTableCaptionElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTableCaptionElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTableCaptionElement,
expose: {
Window: { HTMLTableCaptionElement: HTMLTableCaptionElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTableCaptionElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLTableCellElement() {
throw new TypeError("Illegal constructor");
}
HTMLTableCellElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLTableCellElement.prototype.constructor = HTMLTableCellElement;
HTMLTableCellElement.prototype.toString = function () {
if (this === HTMLTableCellElement.prototype) {
return "[object HTMLTableCellElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTableCellElement.prototype, "colSpan", {
get() {
return this[impl].colSpan;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].colSpan = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "rowSpan", {
get() {
return this[impl].rowSpan;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].rowSpan = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "headers", {
get() {
return utils.tryWrapperForImpl(this[impl].headers);
},
set(V) {
this.headers.value = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "cellIndex", {
get() {
return this[impl].cellIndex;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "axis", {
get() {
const value = this.getAttribute("axis");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("axis", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "height", {
get() {
const value = this.getAttribute("height");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("height", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "ch", {
get() {
const value = this.getAttribute("char");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("char", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "chOff", {
get() {
const value = this.getAttribute("charoff");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("charoff", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "noWrap", {
get() {
return this.hasAttribute("noWrap");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("noWrap", "");
} else {
this.removeAttribute("noWrap");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "vAlign", {
get() {
const value = this.getAttribute("vAlign");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("vAlign", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableCellElement.prototype, "bgColor", {
get() {
const value = this.getAttribute("bgColor");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("bgColor", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTableCellElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTableCellElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTableCellElement,
expose: {
Window: { HTMLTableCellElement: HTMLTableCellElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTableCellElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLTableColElement() {
throw new TypeError("Illegal constructor");
}
HTMLTableColElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLTableColElement.prototype.constructor = HTMLTableColElement;
HTMLTableColElement.prototype.toString = function () {
if (this === HTMLTableColElement.prototype) {
return "[object HTMLTableColElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTableColElement.prototype, "span", {
get() {
const value = parseInt(this.getAttribute("span"));
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["unsigned long"](V);
V = V > 2147483647 ? 0 : V;
this.setAttribute("span", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableColElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableColElement.prototype, "ch", {
get() {
const value = this.getAttribute("char");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("char", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableColElement.prototype, "chOff", {
get() {
const value = this.getAttribute("charoff");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("charoff", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableColElement.prototype, "vAlign", {
get() {
const value = this.getAttribute("vAlign");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("vAlign", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableColElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTableColElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTableColElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTableColElement,
expose: {
Window: { HTMLTableColElement: HTMLTableColElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTableColElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLTableCellElement = require("./HTMLTableCellElement.js");
const impl = utils.implSymbol;
function HTMLTableDataCellElement() {
throw new TypeError("Illegal constructor");
}
HTMLTableDataCellElement.prototype = Object.create(HTMLTableCellElement.interface.prototype);
HTMLTableDataCellElement.prototype.constructor = HTMLTableDataCellElement;
HTMLTableDataCellElement.prototype.toString = function () {
if (this === HTMLTableDataCellElement.prototype) {
return "[object HTMLTableDataCellElementPrototype]";
}
return HTMLTableCellElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTableDataCellElement.prototype, "abbr", {
get() {
const value = this.getAttribute("abbr");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("abbr", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTableDataCellElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTableDataCellElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLTableCellElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTableDataCellElement,
expose: {
Window: { HTMLTableDataCellElement: HTMLTableDataCellElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTableDataCellElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLTableElement() {
throw new TypeError("Illegal constructor");
}
HTMLTableElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLTableElement.prototype.constructor = HTMLTableElement;
HTMLTableElement.prototype.createCaption = function createCaption() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].createCaption.apply(this[impl], args));
};
HTMLTableElement.prototype.deleteCaption = function deleteCaption() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].deleteCaption.apply(this[impl], args);
};
HTMLTableElement.prototype.createTHead = function createTHead() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].createTHead.apply(this[impl], args));
};
HTMLTableElement.prototype.deleteTHead = function deleteTHead() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].deleteTHead.apply(this[impl], args);
};
HTMLTableElement.prototype.createTFoot = function createTFoot() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].createTFoot.apply(this[impl], args));
};
HTMLTableElement.prototype.deleteTFoot = function deleteTFoot() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].deleteTFoot.apply(this[impl], args);
};
HTMLTableElement.prototype.insertRow = function insertRow() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["long"](args[0]);
} else {
args[0] = -1;
}
return utils.tryWrapperForImpl(this[impl].insertRow.apply(this[impl], args));
};
HTMLTableElement.prototype.deleteRow = function deleteRow(index) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'deleteRow' on 'HTMLTableElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["long"](args[0]);
return this[impl].deleteRow.apply(this[impl], args);
};
HTMLTableElement.prototype.toString = function () {
if (this === HTMLTableElement.prototype) {
return "[object HTMLTableElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTableElement.prototype, "caption", {
get() {
return utils.tryWrapperForImpl(this[impl].caption);
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
}
this[impl].caption = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "tHead", {
get() {
return utils.tryWrapperForImpl(this[impl].tHead);
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
}
this[impl].tHead = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "tFoot", {
get() {
return utils.tryWrapperForImpl(this[impl].tFoot);
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
}
this[impl].tFoot = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "tBodies", {
get() {
return utils.tryWrapperForImpl(this[impl].tBodies);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "rows", {
get() {
return utils.tryWrapperForImpl(this[impl].rows);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "border", {
get() {
const value = this.getAttribute("border");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("border", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "frame", {
get() {
const value = this.getAttribute("frame");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("frame", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "rules", {
get() {
const value = this.getAttribute("rules");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("rules", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "summary", {
get() {
const value = this.getAttribute("summary");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("summary", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "bgColor", {
get() {
const value = this.getAttribute("bgColor");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("bgColor", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "cellPadding", {
get() {
const value = this.getAttribute("cellPadding");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("cellPadding", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableElement.prototype, "cellSpacing", {
get() {
const value = this.getAttribute("cellSpacing");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("cellSpacing", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTableElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTableElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTableElement,
expose: {
Window: { HTMLTableElement: HTMLTableElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTableElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLTableCellElement = require("./HTMLTableCellElement.js");
const impl = utils.implSymbol;
function HTMLTableHeaderCellElement() {
throw new TypeError("Illegal constructor");
}
HTMLTableHeaderCellElement.prototype = Object.create(HTMLTableCellElement.interface.prototype);
HTMLTableHeaderCellElement.prototype.constructor = HTMLTableHeaderCellElement;
HTMLTableHeaderCellElement.prototype.toString = function () {
if (this === HTMLTableHeaderCellElement.prototype) {
return "[object HTMLTableHeaderCellElementPrototype]";
}
return HTMLTableCellElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTableHeaderCellElement.prototype, "scope", {
get() {
const value = this.getAttribute("scope");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("scope", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableHeaderCellElement.prototype, "abbr", {
get() {
const value = this.getAttribute("abbr");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("abbr", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableHeaderCellElement.prototype, "sorted", {
get() {
const value = this.getAttribute("sorted");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("sorted", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTableHeaderCellElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTableHeaderCellElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLTableCellElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTableHeaderCellElement,
expose: {
Window: { HTMLTableHeaderCellElement: HTMLTableHeaderCellElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTableHeaderCellElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLTableRowElement() {
throw new TypeError("Illegal constructor");
}
HTMLTableRowElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLTableRowElement.prototype.constructor = HTMLTableRowElement;
HTMLTableRowElement.prototype.insertCell = function insertCell() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["long"](args[0]);
} else {
args[0] = -1;
}
return utils.tryWrapperForImpl(this[impl].insertCell.apply(this[impl], args));
};
HTMLTableRowElement.prototype.deleteCell = function deleteCell(index) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'deleteCell' on 'HTMLTableRowElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["long"](args[0]);
return this[impl].deleteCell.apply(this[impl], args);
};
HTMLTableRowElement.prototype.toString = function () {
if (this === HTMLTableRowElement.prototype) {
return "[object HTMLTableRowElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTableRowElement.prototype, "rowIndex", {
get() {
return this[impl].rowIndex;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableRowElement.prototype, "sectionRowIndex", {
get() {
return this[impl].sectionRowIndex;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableRowElement.prototype, "cells", {
get() {
return utils.tryWrapperForImpl(this[impl].cells);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableRowElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableRowElement.prototype, "ch", {
get() {
const value = this.getAttribute("char");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("char", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableRowElement.prototype, "chOff", {
get() {
const value = this.getAttribute("charoff");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("charoff", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableRowElement.prototype, "vAlign", {
get() {
const value = this.getAttribute("vAlign");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("vAlign", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableRowElement.prototype, "bgColor", {
get() {
const value = this.getAttribute("bgColor");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("bgColor", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTableRowElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTableRowElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTableRowElement,
expose: {
Window: { HTMLTableRowElement: HTMLTableRowElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTableRowElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLTableSectionElement() {
throw new TypeError("Illegal constructor");
}
HTMLTableSectionElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLTableSectionElement.prototype.constructor = HTMLTableSectionElement;
HTMLTableSectionElement.prototype.insertRow = function insertRow() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["long"](args[0]);
} else {
args[0] = -1;
}
return utils.tryWrapperForImpl(this[impl].insertRow.apply(this[impl], args));
};
HTMLTableSectionElement.prototype.deleteRow = function deleteRow(index) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'deleteRow' on 'HTMLTableSectionElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["long"](args[0]);
return this[impl].deleteRow.apply(this[impl], args);
};
HTMLTableSectionElement.prototype.toString = function () {
if (this === HTMLTableSectionElement.prototype) {
return "[object HTMLTableSectionElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTableSectionElement.prototype, "rows", {
get() {
return utils.tryWrapperForImpl(this[impl].rows);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableSectionElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableSectionElement.prototype, "ch", {
get() {
const value = this.getAttribute("char");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("char", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableSectionElement.prototype, "chOff", {
get() {
const value = this.getAttribute("charoff");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("charoff", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTableSectionElement.prototype, "vAlign", {
get() {
const value = this.getAttribute("vAlign");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("vAlign", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTableSectionElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTableSectionElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTableSectionElement,
expose: {
Window: { HTMLTableSectionElement: HTMLTableSectionElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTableSectionElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLTemplateElement() {
throw new TypeError("Illegal constructor");
}
HTMLTemplateElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLTemplateElement.prototype.constructor = HTMLTemplateElement;
HTMLTemplateElement.prototype.toString = function () {
if (this === HTMLTemplateElement.prototype) {
return "[object HTMLTemplateElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTemplateElement.prototype, "content", {
get() {
return utils.tryWrapperForImpl(this[impl].content);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTemplateElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTemplateElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTemplateElement,
expose: {
Window: { HTMLTemplateElement: HTMLTemplateElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTemplateElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLTextAreaElement() {
throw new TypeError("Illegal constructor");
}
HTMLTextAreaElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLTextAreaElement.prototype.constructor = HTMLTextAreaElement;
HTMLTextAreaElement.prototype.select = function select() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].select.apply(this[impl], args);
};
HTMLTextAreaElement.prototype.setRangeText = function setRangeText(replacement) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'setRangeText' on 'HTMLTextAreaElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 4; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].setRangeText.apply(this[impl], args);
};
HTMLTextAreaElement.prototype.setSelectionRange = function setSelectionRange(start, end) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'setSelectionRange' on 'HTMLTextAreaElement': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
args[1] = conversions["unsigned long"](args[1]);
if (args[2] !== undefined) {
args[2] = conversions["DOMString"](args[2]);
}
return this[impl].setSelectionRange.apply(this[impl], args);
};
HTMLTextAreaElement.prototype.toString = function () {
if (this === HTMLTextAreaElement.prototype) {
return "[object HTMLTextAreaElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTextAreaElement.prototype, "autocomplete", {
get() {
const value = this.getAttribute("autocomplete");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("autocomplete", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "autofocus", {
get() {
return this.hasAttribute("autofocus");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("autofocus", "");
} else {
this.removeAttribute("autofocus");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "cols", {
get() {
return this[impl].cols;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].cols = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "dirName", {
get() {
const value = this.getAttribute("dirName");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("dirName", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "disabled", {
get() {
return this.hasAttribute("disabled");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("disabled", "");
} else {
this.removeAttribute("disabled");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "inputMode", {
get() {
const value = this.getAttribute("inputMode");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("inputMode", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "maxLength", {
get() {
const value = parseInt(this.getAttribute("maxLength"));
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["long"](V);
this.setAttribute("maxLength", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "minLength", {
get() {
const value = parseInt(this.getAttribute("minLength"));
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["long"](V);
this.setAttribute("minLength", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "placeholder", {
get() {
const value = this.getAttribute("placeholder");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("placeholder", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "readOnly", {
get() {
return this.hasAttribute("readOnly");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("readOnly", "");
} else {
this.removeAttribute("readOnly");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "required", {
get() {
return this.hasAttribute("required");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("required", "");
} else {
this.removeAttribute("required");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "rows", {
get() {
return this[impl].rows;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].rows = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "wrap", {
get() {
const value = this.getAttribute("wrap");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("wrap", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "type", {
get() {
return this[impl].type;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "defaultValue", {
get() {
return this[impl].defaultValue;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].defaultValue = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "value", {
get() {
return this[impl].value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].value = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "textLength", {
get() {
return this[impl].textLength;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "selectionStart", {
get() {
return this[impl].selectionStart;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["unsigned long"](V);
}
this[impl].selectionStart = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "selectionEnd", {
get() {
return this[impl].selectionEnd;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["unsigned long"](V);
}
this[impl].selectionEnd = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTextAreaElement.prototype, "selectionDirection", {
get() {
return this[impl].selectionDirection;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["DOMString"](V);
}
this[impl].selectionDirection = V;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTextAreaElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTextAreaElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTextAreaElement,
expose: {
Window: { HTMLTextAreaElement: HTMLTextAreaElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTextAreaElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLTimeElement() {
throw new TypeError("Illegal constructor");
}
HTMLTimeElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLTimeElement.prototype.constructor = HTMLTimeElement;
HTMLTimeElement.prototype.toString = function () {
if (this === HTMLTimeElement.prototype) {
return "[object HTMLTimeElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTimeElement.prototype, "dateTime", {
get() {
const value = this.getAttribute("dateTime");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("dateTime", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTimeElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTimeElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTimeElement,
expose: {
Window: { HTMLTimeElement: HTMLTimeElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTimeElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLTitleElement() {
throw new TypeError("Illegal constructor");
}
HTMLTitleElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLTitleElement.prototype.constructor = HTMLTitleElement;
HTMLTitleElement.prototype.toString = function () {
if (this === HTMLTitleElement.prototype) {
return "[object HTMLTitleElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTitleElement.prototype, "text", {
get() {
return this[impl].text;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].text = V;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTitleElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTitleElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTitleElement,
expose: {
Window: { HTMLTitleElement: HTMLTitleElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTitleElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLTrackElement() {
throw new TypeError("Illegal constructor");
}
HTMLTrackElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLTrackElement.prototype.constructor = HTMLTrackElement;
HTMLTrackElement.prototype.toString = function () {
if (this === HTMLTrackElement.prototype) {
return "[object HTMLTrackElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLTrackElement.prototype, "kind", {
get() {
const value = this.getAttribute("kind");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("kind", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTrackElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTrackElement.prototype, "srclang", {
get() {
const value = this.getAttribute("srclang");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("srclang", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTrackElement.prototype, "label", {
get() {
const value = this.getAttribute("label");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("label", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTrackElement.prototype, "default", {
get() {
return this.hasAttribute("default");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("default", "");
} else {
this.removeAttribute("default");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLTrackElement, "NONE", {
value: 0,
enumerable: true
});
Object.defineProperty(HTMLTrackElement.prototype, "NONE", {
value: 0,
enumerable: true
});
Object.defineProperty(HTMLTrackElement, "LOADING", {
value: 1,
enumerable: true
});
Object.defineProperty(HTMLTrackElement.prototype, "LOADING", {
value: 1,
enumerable: true
});
Object.defineProperty(HTMLTrackElement, "LOADED", {
value: 2,
enumerable: true
});
Object.defineProperty(HTMLTrackElement.prototype, "LOADED", {
value: 2,
enumerable: true
});
Object.defineProperty(HTMLTrackElement, "ERROR", {
value: 3,
enumerable: true
});
Object.defineProperty(HTMLTrackElement.prototype, "ERROR", {
value: 3,
enumerable: true
});
Object.defineProperty(HTMLTrackElement.prototype, "readyState", {
get() {
return this[impl].readyState;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLTrackElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLTrackElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLTrackElement,
expose: {
Window: { HTMLTrackElement: HTMLTrackElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLTrackElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLUListElement() {
throw new TypeError("Illegal constructor");
}
HTMLUListElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLUListElement.prototype.constructor = HTMLUListElement;
HTMLUListElement.prototype.toString = function () {
if (this === HTMLUListElement.prototype) {
return "[object HTMLUListElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLUListElement.prototype, "compact", {
get() {
return this.hasAttribute("compact");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("compact", "");
} else {
this.removeAttribute("compact");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLUListElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLUListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLUListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLUListElement,
expose: {
Window: { HTMLUListElement: HTMLUListElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLUListElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLUnknownElement() {
throw new TypeError("Illegal constructor");
}
HTMLUnknownElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLUnknownElement.prototype.constructor = HTMLUnknownElement;
HTMLUnknownElement.prototype.toString = function () {
if (this === HTMLUnknownElement.prototype) {
return "[object HTMLUnknownElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLUnknownElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLUnknownElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLUnknownElement,
expose: {
Window: { HTMLUnknownElement: HTMLUnknownElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLUnknownElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLMediaElement = require("./HTMLMediaElement.js");
const impl = utils.implSymbol;
function HTMLVideoElement() {
throw new TypeError("Illegal constructor");
}
HTMLVideoElement.prototype = Object.create(HTMLMediaElement.interface.prototype);
HTMLVideoElement.prototype.constructor = HTMLVideoElement;
HTMLVideoElement.prototype.toString = function () {
if (this === HTMLVideoElement.prototype) {
return "[object HTMLVideoElementPrototype]";
}
return HTMLMediaElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLVideoElement.prototype, "width", {
get() {
const value = parseInt(this.getAttribute("width"));
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["unsigned long"](V);
V = V > 2147483647 ? 0 : V;
this.setAttribute("width", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLVideoElement.prototype, "height", {
get() {
const value = parseInt(this.getAttribute("height"));
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["unsigned long"](V);
V = V > 2147483647 ? 0 : V;
this.setAttribute("height", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLVideoElement.prototype, "videoWidth", {
get() {
return this[impl].videoWidth;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLVideoElement.prototype, "videoHeight", {
get() {
return this[impl].videoHeight;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLVideoElement.prototype, "poster", {
get() {
return this[impl].poster;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].poster = V;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLVideoElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLVideoElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLMediaElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLVideoElement,
expose: {
Window: { HTMLVideoElement: HTMLVideoElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLVideoElement-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Event = require("./Event.js");
const impl = utils.implSymbol;
const convertHashChangeEventInit = require("./HashChangeEventInit").convert;
function HashChangeEvent(type) {
if (!this || this[impl] || !(this instanceof HashChangeEvent)) {
throw new TypeError("Failed to construct 'HashChangeEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'HashChangeEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertHashChangeEventInit(args[1]);
iface.setup(this, args);
}
HashChangeEvent.prototype = Object.create(Event.interface.prototype);
HashChangeEvent.prototype.constructor = HashChangeEvent;
HashChangeEvent.prototype.toString = function () {
if (this === HashChangeEvent.prototype) {
return "[object HashChangeEventPrototype]";
}
return Event.interface.prototype.toString.call(this);
};
Object.defineProperty(HashChangeEvent.prototype, "oldURL", {
get() {
return this[impl].oldURL;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HashChangeEvent.prototype, "newURL", {
get() {
return this[impl].newURL;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HashChangeEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HashChangeEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Event._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HashChangeEvent,
expose: {
Window: { HashChangeEvent: HashChangeEvent },
Worker: { HashChangeEvent: HashChangeEvent }
}
};
module.exports = iface;
const Impl = require("../events/HashChangeEvent-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit");
module.exports = {
convertInherit(obj, ret) {
EventInit.convertInherit(obj, ret);
let key, value;
key = "newURL";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
}
key = "oldURL";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function History() {
throw new TypeError("Illegal constructor");
}
History.prototype.go = function go() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["long"](args[0]);
} else {
args[0] = 0;
}
return this[impl].go.apply(this[impl], args);
};
History.prototype.back = function back() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].back.apply(this[impl], args);
};
History.prototype.forward = function forward() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].forward.apply(this[impl], args);
};
History.prototype.pushState = function pushState(data, title) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'pushState' on 'History': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["any"](args[0]);
args[1] = conversions["DOMString"](args[1]);
if (args[2] === null || args[2] === undefined) {
args[2] = null;
} else {
if (args[2] !== undefined) {
args[2] = conversions["DOMString"](args[2]);
} else {
args[2] = undefined;
}
}
return this[impl].pushState.apply(this[impl], args);
};
History.prototype.replaceState = function replaceState(data, title) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'replaceState' on 'History': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["any"](args[0]);
args[1] = conversions["DOMString"](args[1]);
if (args[2] === null || args[2] === undefined) {
args[2] = null;
} else {
if (args[2] !== undefined) {
args[2] = conversions["DOMString"](args[2]);
} else {
args[2] = undefined;
}
}
return this[impl].replaceState.apply(this[impl], args);
};
History.prototype.toString = function () {
if (this === History.prototype) {
return "[object HistoryPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(History.prototype, "length", {
get() {
return this[impl].length;
},
enumerable: true,
configurable: true
});
Object.defineProperty(History.prototype, "state", {
get() {
return this[impl].state;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(History.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(History.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: History,
expose: {
Window: { History: History }
}
};
module.exports = iface;
const Impl = require("../window/History-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEvent = require("./UIEvent.js");
const impl = utils.implSymbol;
const convertKeyboardEventInit = require("./KeyboardEventInit").convert;
function KeyboardEvent(typeArg) {
if (!this || this[impl] || !(this instanceof KeyboardEvent)) {
throw new TypeError("Failed to construct 'KeyboardEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'KeyboardEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertKeyboardEventInit(args[1]);
iface.setup(this, args);
}
KeyboardEvent.prototype = Object.create(UIEvent.interface.prototype);
KeyboardEvent.prototype.constructor = KeyboardEvent;
KeyboardEvent.prototype.getModifierState = function getModifierState(keyArg) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getModifierState' on 'KeyboardEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].getModifierState.apply(this[impl], args);
};
KeyboardEvent.prototype.initKeyboardEvent = function initKeyboardEvent(typeArg, bubblesArg, cancelableArg, viewArg, keyArg, locationArg, modifiersListArg, repeat, locale) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 9) {
throw new TypeError("Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': 9 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 9; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["boolean"](args[1]);
args[2] = conversions["boolean"](args[2]);
if (args[3] === null || args[3] === undefined) {
args[3] = null;
} else {
}
args[4] = conversions["DOMString"](args[4]);
args[5] = conversions["unsigned long"](args[5]);
args[6] = conversions["DOMString"](args[6]);
args[7] = conversions["boolean"](args[7]);
args[8] = conversions["DOMString"](args[8]);
return this[impl].initKeyboardEvent.apply(this[impl], args);
};
KeyboardEvent.prototype.toString = function () {
if (this === KeyboardEvent.prototype) {
return "[object KeyboardEventPrototype]";
}
return UIEvent.interface.prototype.toString.call(this);
};
Object.defineProperty(KeyboardEvent, "DOM_KEY_LOCATION_STANDARD", {
value: 0,
enumerable: true
});
Object.defineProperty(KeyboardEvent.prototype, "DOM_KEY_LOCATION_STANDARD", {
value: 0,
enumerable: true
});
Object.defineProperty(KeyboardEvent, "DOM_KEY_LOCATION_LEFT", {
value: 1,
enumerable: true
});
Object.defineProperty(KeyboardEvent.prototype, "DOM_KEY_LOCATION_LEFT", {
value: 1,
enumerable: true
});
Object.defineProperty(KeyboardEvent, "DOM_KEY_LOCATION_RIGHT", {
value: 2,
enumerable: true
});
Object.defineProperty(KeyboardEvent.prototype, "DOM_KEY_LOCATION_RIGHT", {
value: 2,
enumerable: true
});
Object.defineProperty(KeyboardEvent, "DOM_KEY_LOCATION_NUMPAD", {
value: 3,
enumerable: true
});
Object.defineProperty(KeyboardEvent.prototype, "DOM_KEY_LOCATION_NUMPAD", {
value: 3,
enumerable: true
});
Object.defineProperty(KeyboardEvent.prototype, "key", {
get() {
return this[impl].key;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyboardEvent.prototype, "code", {
get() {
return this[impl].code;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyboardEvent.prototype, "location", {
get() {
return this[impl].location;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyboardEvent.prototype, "ctrlKey", {
get() {
return this[impl].ctrlKey;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyboardEvent.prototype, "shiftKey", {
get() {
return this[impl].shiftKey;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyboardEvent.prototype, "altKey", {
get() {
return this[impl].altKey;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyboardEvent.prototype, "metaKey", {
get() {
return this[impl].metaKey;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyboardEvent.prototype, "repeat", {
get() {
return this[impl].repeat;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyboardEvent.prototype, "isComposing", {
get() {
return this[impl].isComposing;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyboardEvent.prototype, "charCode", {
get() {
return this[impl].charCode;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyboardEvent.prototype, "keyCode", {
get() {
return this[impl].keyCode;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyboardEvent.prototype, "which", {
get() {
return this[impl].which;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(KeyboardEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(KeyboardEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
UIEvent._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: KeyboardEvent,
expose: {
Window: { KeyboardEvent: KeyboardEvent }
}
};
module.exports = iface;
const Impl = require("../events/KeyboardEvent-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventModifierInit = require("./EventModifierInit");
module.exports = {
convertInherit(obj, ret) {
EventModifierInit.convertInherit(obj, ret);
let key, value;
key = "charCode";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["unsigned long"](value);
} else {
ret[key] = 0;
}
key = "code";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
} else {
ret[key] = "";
}
key = "isComposing";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "key";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
} else {
ret[key] = "";
}
key = "keyCode";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["unsigned long"](value);
} else {
ret[key] = 0;
}
key = "location";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["unsigned long"](value);
} else {
ret[key] = 0;
}
key = "repeat";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "which";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["unsigned long"](value);
} else {
ret[key] = 0;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function LinkStyle() {
throw new TypeError("Illegal constructor");
}
LinkStyle.prototype.toString = function () {
if (this === LinkStyle.prototype) {
return "[object LinkStylePrototype]";
}
return this[impl].toString();
};
Object.defineProperty(LinkStyle.prototype, "sheet", {
get() {
return utils.tryWrapperForImpl(this[impl].sheet);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(LinkStyle.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(LinkStyle.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: LinkStyle,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/LinkStyle-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function Location() {
throw new TypeError("Illegal constructor");
}
Location.prototype.assign = function assign(url) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'assign' on 'Location': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
return this[impl].assign.apply(this[impl], args);
};
Location.prototype.replace = function replace(url) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'replace' on 'Location': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
return this[impl].replace.apply(this[impl], args);
};
Location.prototype.reload = function reload() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].reload.apply(this[impl], args);
};
Object.defineProperty(Location.prototype, "href", {
get() {
return this[impl].href;
},
set(V) {
V = conversions["USVString"](V);
this[impl].href = V;
},
enumerable: true,
configurable: true
});
Location.prototype.toString = function () {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl].href;;
};
Object.defineProperty(Location.prototype, "origin", {
get() {
return this[impl].origin;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Location.prototype, "protocol", {
get() {
return this[impl].protocol;
},
set(V) {
V = conversions["USVString"](V);
this[impl].protocol = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Location.prototype, "host", {
get() {
return this[impl].host;
},
set(V) {
V = conversions["USVString"](V);
this[impl].host = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Location.prototype, "hostname", {
get() {
return this[impl].hostname;
},
set(V) {
V = conversions["USVString"](V);
this[impl].hostname = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Location.prototype, "port", {
get() {
return this[impl].port;
},
set(V) {
V = conversions["USVString"](V);
this[impl].port = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Location.prototype, "pathname", {
get() {
return this[impl].pathname;
},
set(V) {
V = conversions["USVString"](V);
this[impl].pathname = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Location.prototype, "search", {
get() {
return this[impl].search;
},
set(V) {
V = conversions["USVString"](V);
this[impl].search = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Location.prototype, "hash", {
get() {
return this[impl].hash;
},
set(V) {
V = conversions["USVString"](V);
this[impl].hash = V;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Location.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Location.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Object.defineProperty(obj, "valueOf", {
value: function valueOf() { return this; },
enumerable: true
});
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Location,
expose: {
Window: { Location: Location }
}
};
module.exports = iface;
const Impl = require("../window/Location-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Event = require("./Event.js");
const impl = utils.implSymbol;
const convertMessageEventInit = require("./MessageEventInit").convert;
function MessageEvent(type) {
if (!this || this[impl] || !(this instanceof MessageEvent)) {
throw new TypeError("Failed to construct 'MessageEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'MessageEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertMessageEventInit(args[1]);
iface.setup(this, args);
}
MessageEvent.prototype = Object.create(Event.interface.prototype);
MessageEvent.prototype.constructor = MessageEvent;
MessageEvent.prototype.initMessageEvent = function initMessageEvent(type, bubbles, cancelable, data, origin, lastEventId, source, ports) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 8) {
throw new TypeError("Failed to execute 'initMessageEvent' on 'MessageEvent': 8 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 8; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["boolean"](args[1]);
args[2] = conversions["boolean"](args[2]);
args[3] = conversions["any"](args[3]);
args[4] = conversions["DOMString"](args[4]);
args[5] = conversions["DOMString"](args[5]);
if (args[6] === null || args[6] === undefined) {
args[6] = null;
} else {
}
if (args[7] === null || args[7] === undefined) {
args[7] = null;
} else {
}
return this[impl].initMessageEvent.apply(this[impl], args);
};
MessageEvent.prototype.toString = function () {
if (this === MessageEvent.prototype) {
return "[object MessageEventPrototype]";
}
return Event.interface.prototype.toString.call(this);
};
Object.defineProperty(MessageEvent.prototype, "data", {
get() {
return this[impl].data;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MessageEvent.prototype, "origin", {
get() {
return this[impl].origin;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MessageEvent.prototype, "lastEventId", {
get() {
return this[impl].lastEventId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MessageEvent.prototype, "source", {
get() {
return utils.tryWrapperForImpl(this[impl].source);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MessageEvent.prototype, "ports", {
get() {
return utils.tryWrapperForImpl(this[impl].ports);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(MessageEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(MessageEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Event._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: MessageEvent,
expose: {
Window: { MessageEvent: MessageEvent },
Worker: { MessageEvent: MessageEvent }
}
};
module.exports = iface;
const Impl = require("../events/MessageEvent-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit");
module.exports = {
convertInherit(obj, ret) {
EventInit.convertInherit(obj, ret);
let key, value;
key = "data";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["any"](value);
}
key = "lastEventId";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
}
key = "origin";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
}
key = "ports";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = (value);
}
key = "source";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = (value);
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEvent = require("./UIEvent.js");
const impl = utils.implSymbol;
const convertMouseEventInit = require("./MouseEventInit").convert;
function MouseEvent(typeArg) {
if (!this || this[impl] || !(this instanceof MouseEvent)) {
throw new TypeError("Failed to construct 'MouseEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'MouseEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertMouseEventInit(args[1]);
iface.setup(this, args);
}
MouseEvent.prototype = Object.create(UIEvent.interface.prototype);
MouseEvent.prototype.constructor = MouseEvent;
MouseEvent.prototype.getModifierState = function getModifierState(keyArg) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getModifierState' on 'MouseEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].getModifierState.apply(this[impl], args);
};
MouseEvent.prototype.initMouseEvent = function initMouseEvent(typeArg, bubblesArg, cancelableArg, viewArg, detailArg, screenXArg, screenYArg, clientXArg, clientYArg, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, buttonArg, relatedTargetArg) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 15) {
throw new TypeError("Failed to execute 'initMouseEvent' on 'MouseEvent': 15 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 15; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["boolean"](args[1]);
args[2] = conversions["boolean"](args[2]);
if (args[3] === null || args[3] === undefined) {
args[3] = null;
} else {
}
args[4] = conversions["long"](args[4]);
args[5] = conversions["long"](args[5]);
args[6] = conversions["long"](args[6]);
args[7] = conversions["long"](args[7]);
args[8] = conversions["long"](args[8]);
args[9] = conversions["boolean"](args[9]);
args[10] = conversions["boolean"](args[10]);
args[11] = conversions["boolean"](args[11]);
args[12] = conversions["boolean"](args[12]);
args[13] = conversions["short"](args[13]);
if (args[14] === null || args[14] === undefined) {
args[14] = null;
} else {
}
return this[impl].initMouseEvent.apply(this[impl], args);
};
MouseEvent.prototype.toString = function () {
if (this === MouseEvent.prototype) {
return "[object MouseEventPrototype]";
}
return UIEvent.interface.prototype.toString.call(this);
};
Object.defineProperty(MouseEvent.prototype, "screenX", {
get() {
return this[impl].screenX;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MouseEvent.prototype, "screenY", {
get() {
return this[impl].screenY;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MouseEvent.prototype, "clientX", {
get() {
return this[impl].clientX;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MouseEvent.prototype, "clientY", {
get() {
return this[impl].clientY;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MouseEvent.prototype, "ctrlKey", {
get() {
return this[impl].ctrlKey;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MouseEvent.prototype, "shiftKey", {
get() {
return this[impl].shiftKey;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MouseEvent.prototype, "altKey", {
get() {
return this[impl].altKey;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MouseEvent.prototype, "metaKey", {
get() {
return this[impl].metaKey;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MouseEvent.prototype, "button", {
get() {
return this[impl].button;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MouseEvent.prototype, "relatedTarget", {
get() {
return utils.tryWrapperForImpl(this[impl].relatedTarget);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MouseEvent.prototype, "buttons", {
get() {
return this[impl].buttons;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(MouseEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(MouseEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
UIEvent._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: MouseEvent,
expose: {
Window: { MouseEvent: MouseEvent }
}
};
module.exports = iface;
const Impl = require("../events/MouseEvent-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventModifierInit = require("./EventModifierInit");
module.exports = {
convertInherit(obj, ret) {
EventModifierInit.convertInherit(obj, ret);
let key, value;
key = "button";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["short"](value);
} else {
ret[key] = 0;
}
key = "buttons";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["unsigned short"](value);
} else {
ret[key] = 0;
}
key = "clientX";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["long"](value);
} else {
ret[key] = 0;
}
key = "clientY";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["long"](value);
} else {
ret[key] = 0;
}
key = "relatedTarget";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = (value);
} else {
ret[key] = null;
}
key = "screenX";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["long"](value);
} else {
ret[key] = 0;
}
key = "screenY";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["long"](value);
} else {
ret[key] = 0;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const NavigatorID = require("./NavigatorID.js");
const NavigatorLanguage = require("./NavigatorLanguage.js");
const NavigatorOnLine = require("./NavigatorOnLine.js");
const NavigatorCookies = require("./NavigatorCookies.js");
const NavigatorPlugins = require("./NavigatorPlugins.js");
const NavigatorConcurrentHardware = require("./NavigatorConcurrentHardware.js");
function Navigator() {
throw new TypeError("Illegal constructor");
}
mixin(Navigator.prototype, NavigatorID.interface.prototype);
NavigatorID.mixedInto.push(Navigator);
mixin(Navigator.prototype, NavigatorLanguage.interface.prototype);
NavigatorLanguage.mixedInto.push(Navigator);
mixin(Navigator.prototype, NavigatorOnLine.interface.prototype);
NavigatorOnLine.mixedInto.push(Navigator);
mixin(Navigator.prototype, NavigatorCookies.interface.prototype);
NavigatorCookies.mixedInto.push(Navigator);
mixin(Navigator.prototype, NavigatorPlugins.interface.prototype);
NavigatorPlugins.mixedInto.push(Navigator);
mixin(Navigator.prototype, NavigatorConcurrentHardware.interface.prototype);
NavigatorConcurrentHardware.mixedInto.push(Navigator);
Navigator.prototype.toString = function () {
if (this === Navigator.prototype) {
return "[object NavigatorPrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Navigator.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Navigator.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Navigator,
expose: {
Window: { Navigator: Navigator }
}
};
module.exports = iface;
const Impl = require("../navigator/Navigator-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function NavigatorConcurrentHardware() {
throw new TypeError("Illegal constructor");
}
NavigatorConcurrentHardware.prototype.toString = function () {
if (this === NavigatorConcurrentHardware.prototype) {
return "[object NavigatorConcurrentHardwarePrototype]";
}
return this[impl].toString();
};
Object.defineProperty(NavigatorConcurrentHardware.prototype, "hardwareConcurrency", {
get() {
return this[impl].hardwareConcurrency;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(NavigatorConcurrentHardware.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(NavigatorConcurrentHardware.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: NavigatorConcurrentHardware,
expose: {
}
};
module.exports = iface;
const Impl = require("../navigator/NavigatorConcurrentHardware-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function NavigatorCookies() {
throw new TypeError("Illegal constructor");
}
NavigatorCookies.prototype.toString = function () {
if (this === NavigatorCookies.prototype) {
return "[object NavigatorCookiesPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(NavigatorCookies.prototype, "cookieEnabled", {
get() {
return this[impl].cookieEnabled;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(NavigatorCookies.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(NavigatorCookies.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: NavigatorCookies,
expose: {
}
};
module.exports = iface;
const Impl = require("../navigator/NavigatorCookies-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function NavigatorID() {
throw new TypeError("Illegal constructor");
}
NavigatorID.prototype.toString = function () {
if (this === NavigatorID.prototype) {
return "[object NavigatorIDPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(NavigatorID.prototype, "appCodeName", {
get() {
return this[impl].appCodeName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NavigatorID.prototype, "appName", {
get() {
return this[impl].appName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NavigatorID.prototype, "appVersion", {
get() {
return this[impl].appVersion;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NavigatorID.prototype, "platform", {
get() {
return this[impl].platform;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NavigatorID.prototype, "product", {
get() {
return this[impl].product;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NavigatorID.prototype, "productSub", {
get() {
return this[impl].productSub;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NavigatorID.prototype, "userAgent", {
get() {
return this[impl].userAgent;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NavigatorID.prototype, "vendor", {
get() {
return this[impl].vendor;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NavigatorID.prototype, "vendorSub", {
get() {
return this[impl].vendorSub;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(NavigatorID.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(NavigatorID.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: NavigatorID,
expose: {
}
};
module.exports = iface;
const Impl = require("../navigator/NavigatorID-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function NavigatorLanguage() {
throw new TypeError("Illegal constructor");
}
NavigatorLanguage.prototype.toString = function () {
if (this === NavigatorLanguage.prototype) {
return "[object NavigatorLanguagePrototype]";
}
return this[impl].toString();
};
Object.defineProperty(NavigatorLanguage.prototype, "language", {
get() {
return this[impl].language;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NavigatorLanguage.prototype, "languages", {
get() {
return utils.tryWrapperForImpl(this[impl].languages);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(NavigatorLanguage.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(NavigatorLanguage.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: NavigatorLanguage,
expose: {
}
};
module.exports = iface;
const Impl = require("../navigator/NavigatorLanguage-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function NavigatorOnLine() {
throw new TypeError("Illegal constructor");
}
NavigatorOnLine.prototype.toString = function () {
if (this === NavigatorOnLine.prototype) {
return "[object NavigatorOnLinePrototype]";
}
return this[impl].toString();
};
Object.defineProperty(NavigatorOnLine.prototype, "onLine", {
get() {
return this[impl].onLine;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(NavigatorOnLine.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(NavigatorOnLine.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: NavigatorOnLine,
expose: {
}
};
module.exports = iface;
const Impl = require("../navigator/NavigatorOnLine-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function NavigatorPlugins() {
throw new TypeError("Illegal constructor");
}
NavigatorPlugins.prototype.javaEnabled = function javaEnabled() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].javaEnabled.apply(this[impl], args);
};
NavigatorPlugins.prototype.toString = function () {
if (this === NavigatorPlugins.prototype) {
return "[object NavigatorPluginsPrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(NavigatorPlugins.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(NavigatorPlugins.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: NavigatorPlugins,
expose: {
}
};
module.exports = iface;
const Impl = require("../navigator/NavigatorPlugins-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventTarget = require("./EventTarget.js");
const impl = utils.implSymbol;
function Node() {
throw new TypeError("Illegal constructor");
}
Node.prototype = Object.create(EventTarget.interface.prototype);
Node.prototype.constructor = Node;
Node.prototype.hasChildNodes = function hasChildNodes() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].hasChildNodes.apply(this[impl], args);
};
Node.prototype.normalize = function normalize() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].normalize.apply(this[impl], args);
};
Node.prototype.cloneNode = function cloneNode() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["boolean"](args[0]);
} else {
args[0] = false;
}
return utils.tryWrapperForImpl(this[impl].cloneNode.apply(this[impl], args));
};
Node.prototype.isEqualNode = function isEqualNode(otherNode) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'isEqualNode' on 'Node': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
}
return this[impl].isEqualNode.apply(this[impl], args);
};
Node.prototype.compareDocumentPosition = function compareDocumentPosition(other) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'compareDocumentPosition' on 'Node': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].compareDocumentPosition.apply(this[impl], args);
};
Node.prototype.contains = function contains(other) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'contains' on 'Node': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
}
return this[impl].contains.apply(this[impl], args);
};
Node.prototype.insertBefore = function insertBefore(node, child) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'insertBefore' on 'Node': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[1] === null || args[1] === undefined) {
args[1] = null;
} else {
}
return utils.tryWrapperForImpl(this[impl].insertBefore.apply(this[impl], args));
};
Node.prototype.appendChild = function appendChild(node) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'appendChild' on 'Node': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].appendChild.apply(this[impl], args));
};
Node.prototype.replaceChild = function replaceChild(node, child) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'replaceChild' on 'Node': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].replaceChild.apply(this[impl], args));
};
Node.prototype.removeChild = function removeChild(child) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'removeChild' on 'Node': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].removeChild.apply(this[impl], args));
};
Node.prototype.toString = function () {
if (this === Node.prototype) {
return "[object NodePrototype]";
}
return EventTarget.interface.prototype.toString.call(this);
};
Object.defineProperty(Node, "ELEMENT_NODE", {
value: 1,
enumerable: true
});
Object.defineProperty(Node.prototype, "ELEMENT_NODE", {
value: 1,
enumerable: true
});
Object.defineProperty(Node, "ATTRIBUTE_NODE", {
value: 2,
enumerable: true
});
Object.defineProperty(Node.prototype, "ATTRIBUTE_NODE", {
value: 2,
enumerable: true
});
Object.defineProperty(Node, "TEXT_NODE", {
value: 3,
enumerable: true
});
Object.defineProperty(Node.prototype, "TEXT_NODE", {
value: 3,
enumerable: true
});
Object.defineProperty(Node, "CDATA_SECTION_NODE", {
value: 4,
enumerable: true
});
Object.defineProperty(Node.prototype, "CDATA_SECTION_NODE", {
value: 4,
enumerable: true
});
Object.defineProperty(Node, "ENTITY_REFERENCE_NODE", {
value: 5,
enumerable: true
});
Object.defineProperty(Node.prototype, "ENTITY_REFERENCE_NODE", {
value: 5,
enumerable: true
});
Object.defineProperty(Node, "ENTITY_NODE", {
value: 6,
enumerable: true
});
Object.defineProperty(Node.prototype, "ENTITY_NODE", {
value: 6,
enumerable: true
});
Object.defineProperty(Node, "PROCESSING_INSTRUCTION_NODE", {
value: 7,
enumerable: true
});
Object.defineProperty(Node.prototype, "PROCESSING_INSTRUCTION_NODE", {
value: 7,
enumerable: true
});
Object.defineProperty(Node, "COMMENT_NODE", {
value: 8,
enumerable: true
});
Object.defineProperty(Node.prototype, "COMMENT_NODE", {
value: 8,
enumerable: true
});
Object.defineProperty(Node, "DOCUMENT_NODE", {
value: 9,
enumerable: true
});
Object.defineProperty(Node.prototype, "DOCUMENT_NODE", {
value: 9,
enumerable: true
});
Object.defineProperty(Node, "DOCUMENT_TYPE_NODE", {
value: 10,
enumerable: true
});
Object.defineProperty(Node.prototype, "DOCUMENT_TYPE_NODE", {
value: 10,
enumerable: true
});
Object.defineProperty(Node, "DOCUMENT_FRAGMENT_NODE", {
value: 11,
enumerable: true
});
Object.defineProperty(Node.prototype, "DOCUMENT_FRAGMENT_NODE", {
value: 11,
enumerable: true
});
Object.defineProperty(Node, "NOTATION_NODE", {
value: 12,
enumerable: true
});
Object.defineProperty(Node.prototype, "NOTATION_NODE", {
value: 12,
enumerable: true
});
Object.defineProperty(Node.prototype, "nodeType", {
get() {
return this[impl].nodeType;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "nodeName", {
get() {
return this[impl].nodeName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "baseURI", {
get() {
return this[impl].baseURI;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "ownerDocument", {
get() {
return utils.tryWrapperForImpl(this[impl].ownerDocument);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "parentNode", {
get() {
return utils.tryWrapperForImpl(this[impl].parentNode);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "parentElement", {
get() {
return utils.tryWrapperForImpl(this[impl].parentElement);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "childNodes", {
get() {
return utils.tryWrapperForImpl(this[impl].childNodes);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "firstChild", {
get() {
return utils.tryWrapperForImpl(this[impl].firstChild);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "lastChild", {
get() {
return utils.tryWrapperForImpl(this[impl].lastChild);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "previousSibling", {
get() {
return utils.tryWrapperForImpl(this[impl].previousSibling);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "nextSibling", {
get() {
return utils.tryWrapperForImpl(this[impl].nextSibling);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "nodeValue", {
get() {
return this[impl].nodeValue;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["DOMString"](V);
}
this[impl].nodeValue = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, "textContent", {
get() {
return this[impl].textContent;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["DOMString"](V);
}
this[impl].textContent = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Node, "DOCUMENT_POSITION_DISCONNECTED", {
value: 1,
enumerable: true
});
Object.defineProperty(Node.prototype, "DOCUMENT_POSITION_DISCONNECTED", {
value: 1,
enumerable: true
});
Object.defineProperty(Node, "DOCUMENT_POSITION_PRECEDING", {
value: 2,
enumerable: true
});
Object.defineProperty(Node.prototype, "DOCUMENT_POSITION_PRECEDING", {
value: 2,
enumerable: true
});
Object.defineProperty(Node, "DOCUMENT_POSITION_FOLLOWING", {
value: 4,
enumerable: true
});
Object.defineProperty(Node.prototype, "DOCUMENT_POSITION_FOLLOWING", {
value: 4,
enumerable: true
});
Object.defineProperty(Node, "DOCUMENT_POSITION_CONTAINS", {
value: 8,
enumerable: true
});
Object.defineProperty(Node.prototype, "DOCUMENT_POSITION_CONTAINS", {
value: 8,
enumerable: true
});
Object.defineProperty(Node, "DOCUMENT_POSITION_CONTAINED_BY", {
value: 16,
enumerable: true
});
Object.defineProperty(Node.prototype, "DOCUMENT_POSITION_CONTAINED_BY", {
value: 16,
enumerable: true
});
Object.defineProperty(Node, "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", {
value: 32,
enumerable: true
});
Object.defineProperty(Node.prototype, "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", {
value: 32,
enumerable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Node.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Node.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
EventTarget._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Node,
expose: {
Window: { Node: Node }
}
};
module.exports = iface;
const Impl = require("../nodes/Node-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function NonDocumentTypeChildNode() {
throw new TypeError("Illegal constructor");
}
NonDocumentTypeChildNode.prototype.toString = function () {
if (this === NonDocumentTypeChildNode.prototype) {
return "[object NonDocumentTypeChildNodePrototype]";
}
return this[impl].toString();
};
Object.defineProperty(NonDocumentTypeChildNode.prototype, "previousElementSibling", {
get() {
return utils.tryWrapperForImpl(this[impl].previousElementSibling);
},
enumerable: true,
configurable: true
});
Object.defineProperty(NonDocumentTypeChildNode.prototype, "nextElementSibling", {
get() {
return utils.tryWrapperForImpl(this[impl].nextElementSibling);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(NonDocumentTypeChildNode.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(NonDocumentTypeChildNode.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: NonDocumentTypeChildNode,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/NonDocumentTypeChildNode-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function NonElementParentNode() {
throw new TypeError("Illegal constructor");
}
NonElementParentNode.prototype.getElementById = function getElementById(elementId) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getElementById' on 'NonElementParentNode': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getElementById.apply(this[impl], args));
};
NonElementParentNode.prototype.toString = function () {
if (this === NonElementParentNode.prototype) {
return "[object NonElementParentNodePrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(NonElementParentNode.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(NonElementParentNode.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: NonElementParentNode,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/NonElementParentNode-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function ParentNode() {
throw new TypeError("Illegal constructor");
}
ParentNode.prototype.querySelector = function querySelector(selectors) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'querySelector' on 'ParentNode': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].querySelector.apply(this[impl], args));
};
ParentNode.prototype.querySelectorAll = function querySelectorAll(selectors) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'querySelectorAll' on 'ParentNode': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].querySelectorAll.apply(this[impl], args));
};
ParentNode.prototype.toString = function () {
if (this === ParentNode.prototype) {
return "[object ParentNodePrototype]";
}
return this[impl].toString();
};
Object.defineProperty(ParentNode.prototype, "children", {
get() {
return utils.tryWrapperForImpl(this[impl].children);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ParentNode.prototype, "firstElementChild", {
get() {
return utils.tryWrapperForImpl(this[impl].firstElementChild);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ParentNode.prototype, "lastElementChild", {
get() {
return utils.tryWrapperForImpl(this[impl].lastElementChild);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ParentNode.prototype, "childElementCount", {
get() {
return this[impl].childElementCount;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(ParentNode.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(ParentNode.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: ParentNode,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/ParentNode-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Event = require("./Event.js");
const impl = utils.implSymbol;
const convertPopStateEventInit = require("./PopStateEventInit").convert;
function PopStateEvent(type) {
if (!this || this[impl] || !(this instanceof PopStateEvent)) {
throw new TypeError("Failed to construct 'PopStateEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'PopStateEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertPopStateEventInit(args[1]);
iface.setup(this, args);
}
PopStateEvent.prototype = Object.create(Event.interface.prototype);
PopStateEvent.prototype.constructor = PopStateEvent;
PopStateEvent.prototype.toString = function () {
if (this === PopStateEvent.prototype) {
return "[object PopStateEventPrototype]";
}
return Event.interface.prototype.toString.call(this);
};
Object.defineProperty(PopStateEvent.prototype, "state", {
get() {
return this[impl].state;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(PopStateEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(PopStateEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Event._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: PopStateEvent,
expose: {
Window: { PopStateEvent: PopStateEvent },
Worker: { PopStateEvent: PopStateEvent }
}
};
module.exports = iface;
const Impl = require("../events/PopStateEvent-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit");
module.exports = {
convertInherit(obj, ret) {
EventInit.convertInherit(obj, ret);
let key, value;
key = "state";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["any"](value);
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CharacterData = require("./CharacterData.js");
const impl = utils.implSymbol;
function ProcessingInstruction() {
throw new TypeError("Illegal constructor");
}
ProcessingInstruction.prototype = Object.create(CharacterData.interface.prototype);
ProcessingInstruction.prototype.constructor = ProcessingInstruction;
ProcessingInstruction.prototype.toString = function () {
if (this === ProcessingInstruction.prototype) {
return "[object ProcessingInstructionPrototype]";
}
return CharacterData.interface.prototype.toString.call(this);
};
Object.defineProperty(ProcessingInstruction.prototype, "target", {
get() {
return this[impl].target;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(ProcessingInstruction.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(ProcessingInstruction.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
CharacterData._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: ProcessingInstruction,
expose: {
Window: { ProcessingInstruction: ProcessingInstruction }
}
};
module.exports = iface;
const Impl = require("../nodes/ProcessingInstruction-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Event = require("./Event.js");
const impl = utils.implSymbol;
const convertProgressEventInit = require("./ProgressEventInit").convert;
function ProgressEvent(type) {
if (!this || this[impl] || !(this instanceof ProgressEvent)) {
throw new TypeError("Failed to construct 'ProgressEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'ProgressEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertProgressEventInit(args[1]);
iface.setup(this, args);
}
ProgressEvent.prototype = Object.create(Event.interface.prototype);
ProgressEvent.prototype.constructor = ProgressEvent;
ProgressEvent.prototype.toString = function () {
if (this === ProgressEvent.prototype) {
return "[object ProgressEventPrototype]";
}
return Event.interface.prototype.toString.call(this);
};
Object.defineProperty(ProgressEvent.prototype, "lengthComputable", {
get() {
return this[impl].lengthComputable;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ProgressEvent.prototype, "loaded", {
get() {
return this[impl].loaded;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ProgressEvent.prototype, "total", {
get() {
return this[impl].total;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(ProgressEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(ProgressEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Event._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: ProgressEvent,
expose: {
Window: { ProgressEvent: ProgressEvent },
DedicatedWorker: { ProgressEvent: ProgressEvent },
SharedWorker: { ProgressEvent: ProgressEvent }
}
};
module.exports = iface;
const Impl = require("../events/ProgressEvent-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit");
module.exports = {
convertInherit(obj, ret) {
EventInit.convertInherit(obj, ret);
let key, value;
key = "lengthComputable";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "loaded";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["unsigned long long"](value);
} else {
ret[key] = 0;
}
key = "total";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["unsigned long long"](value);
} else {
ret[key] = 0;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CharacterData = require("./CharacterData.js");
const impl = utils.implSymbol;
function Text() {
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
} else {
args[0] = "";
}
iface.setup(this, args);
}
Text.prototype = Object.create(CharacterData.interface.prototype);
Text.prototype.constructor = Text;
Text.prototype.splitText = function splitText(offset) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'splitText' on 'Text': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
return utils.tryWrapperForImpl(this[impl].splitText.apply(this[impl], args));
};
Text.prototype.toString = function () {
if (this === Text.prototype) {
return "[object TextPrototype]";
}
return CharacterData.interface.prototype.toString.call(this);
};
Object.defineProperty(Text.prototype, "wholeText", {
get() {
return this[impl].wholeText;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Text.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Text.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
CharacterData._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Text,
expose: {
Window: { Text: Text }
}
};
module.exports = iface;
const Impl = require("../nodes/Text-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEvent = require("./UIEvent.js");
const impl = utils.implSymbol;
function TouchEvent() {
throw new TypeError("Illegal constructor");
}
TouchEvent.prototype = Object.create(UIEvent.interface.prototype);
TouchEvent.prototype.constructor = TouchEvent;
TouchEvent.prototype.toString = function () {
if (this === TouchEvent.prototype) {
return "[object TouchEventPrototype]";
}
return UIEvent.interface.prototype.toString.call(this);
};
Object.defineProperty(TouchEvent.prototype, "touches", {
get() {
return utils.tryWrapperForImpl(this[impl].touches);
},
enumerable: true,
configurable: true
});
Object.defineProperty(TouchEvent.prototype, "targetTouches", {
get() {
return utils.tryWrapperForImpl(this[impl].targetTouches);
},
enumerable: true,
configurable: true
});
Object.defineProperty(TouchEvent.prototype, "changedTouches", {
get() {
return utils.tryWrapperForImpl(this[impl].changedTouches);
},
enumerable: true,
configurable: true
});
Object.defineProperty(TouchEvent.prototype, "altKey", {
get() {
return this[impl].altKey;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TouchEvent.prototype, "metaKey", {
get() {
return this[impl].metaKey;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TouchEvent.prototype, "ctrlKey", {
get() {
return this[impl].ctrlKey;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TouchEvent.prototype, "shiftKey", {
get() {
return this[impl].shiftKey;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(TouchEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(TouchEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
UIEvent._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: TouchEvent,
expose: {
Window: { TouchEvent: TouchEvent }
}
};
module.exports = iface;
const Impl = require("../events/TouchEvent-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function TreeWalker() {
throw new TypeError("Illegal constructor");
}
TreeWalker.prototype.parentNode = function parentNode() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].parentNode.apply(this[impl], args));
};
TreeWalker.prototype.firstChild = function firstChild() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].firstChild.apply(this[impl], args));
};
TreeWalker.prototype.lastChild = function lastChild() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].lastChild.apply(this[impl], args));
};
TreeWalker.prototype.previousSibling = function previousSibling() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].previousSibling.apply(this[impl], args));
};
TreeWalker.prototype.nextSibling = function nextSibling() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].nextSibling.apply(this[impl], args));
};
TreeWalker.prototype.previousNode = function previousNode() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].previousNode.apply(this[impl], args));
};
TreeWalker.prototype.nextNode = function nextNode() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].nextNode.apply(this[impl], args));
};
TreeWalker.prototype.toString = function () {
if (this === TreeWalker.prototype) {
return "[object TreeWalkerPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(TreeWalker.prototype, "root", {
get() {
return utils.tryWrapperForImpl(this[impl].root);
},
enumerable: true,
configurable: true
});
Object.defineProperty(TreeWalker.prototype, "whatToShow", {
get() {
return this[impl].whatToShow;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TreeWalker.prototype, "filter", {
get() {
return utils.tryWrapperForImpl(this[impl].filter);
},
enumerable: true,
configurable: true
});
Object.defineProperty(TreeWalker.prototype, "currentNode", {
get() {
return utils.tryWrapperForImpl(this[impl].currentNode);
},
set(V) {
this[impl].currentNode = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(TreeWalker.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(TreeWalker.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: TreeWalker,
expose: {
Window: { TreeWalker: TreeWalker }
}
};
module.exports = iface;
const Impl = require("../traversal/TreeWalker-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Event = require("./Event.js");
const impl = utils.implSymbol;
const convertUIEventInit = require("./UIEventInit").convert;
function UIEvent(type) {
if (!this || this[impl] || !(this instanceof UIEvent)) {
throw new TypeError("Failed to construct 'UIEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'UIEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertUIEventInit(args[1]);
iface.setup(this, args);
}
UIEvent.prototype = Object.create(Event.interface.prototype);
UIEvent.prototype.constructor = UIEvent;
UIEvent.prototype.initUIEvent = function initUIEvent(typeArg, bubblesArg, cancelableArg, viewArg, detailArg) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 5) {
throw new TypeError("Failed to execute 'initUIEvent' on 'UIEvent': 5 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 5; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["boolean"](args[1]);
args[2] = conversions["boolean"](args[2]);
if (args[3] === null || args[3] === undefined) {
args[3] = null;
} else {
}
args[4] = conversions["long"](args[4]);
return this[impl].initUIEvent.apply(this[impl], args);
};
UIEvent.prototype.toString = function () {
if (this === UIEvent.prototype) {
return "[object UIEventPrototype]";
}
return Event.interface.prototype.toString.call(this);
};
Object.defineProperty(UIEvent.prototype, "view", {
get() {
return utils.tryWrapperForImpl(this[impl].view);
},
enumerable: true,
configurable: true
});
Object.defineProperty(UIEvent.prototype, "detail", {
get() {
return this[impl].detail;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(UIEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(UIEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Event._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: UIEvent,
expose: {
Window: { UIEvent: UIEvent }
}
};
module.exports = iface;
const Impl = require("../events/UIEvent-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit");
module.exports = {
convertInherit(obj, ret) {
EventInit.convertInherit(obj, ret);
let key, value;
key = "detail";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["long"](value);
} else {
ret[key] = 0;
}
key = "view";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = (value);
} else {
ret[key] = null;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function WindowEventHandlers() {
throw new TypeError("Illegal constructor");
}
WindowEventHandlers.prototype.toString = function () {
if (this === WindowEventHandlers.prototype) {
return "[object WindowEventHandlersPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(WindowEventHandlers.prototype, "onafterprint", {
get() {
return utils.tryWrapperForImpl(this[impl].onafterprint);
},
set(V) {
this[impl].onafterprint = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onbeforeprint", {
get() {
return utils.tryWrapperForImpl(this[impl].onbeforeprint);
},
set(V) {
this[impl].onbeforeprint = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onbeforeunload", {
get() {
return utils.tryWrapperForImpl(this[impl].onbeforeunload);
},
set(V) {
this[impl].onbeforeunload = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onhashchange", {
get() {
return utils.tryWrapperForImpl(this[impl].onhashchange);
},
set(V) {
this[impl].onhashchange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onlanguagechange", {
get() {
return utils.tryWrapperForImpl(this[impl].onlanguagechange);
},
set(V) {
this[impl].onlanguagechange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onmessage", {
get() {
return utils.tryWrapperForImpl(this[impl].onmessage);
},
set(V) {
this[impl].onmessage = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onoffline", {
get() {
return utils.tryWrapperForImpl(this[impl].onoffline);
},
set(V) {
this[impl].onoffline = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "ononline", {
get() {
return utils.tryWrapperForImpl(this[impl].ononline);
},
set(V) {
this[impl].ononline = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onpagehide", {
get() {
return utils.tryWrapperForImpl(this[impl].onpagehide);
},
set(V) {
this[impl].onpagehide = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onpageshow", {
get() {
return utils.tryWrapperForImpl(this[impl].onpageshow);
},
set(V) {
this[impl].onpageshow = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onpopstate", {
get() {
return utils.tryWrapperForImpl(this[impl].onpopstate);
},
set(V) {
this[impl].onpopstate = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onrejectionhandled", {
get() {
return utils.tryWrapperForImpl(this[impl].onrejectionhandled);
},
set(V) {
this[impl].onrejectionhandled = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onstorage", {
get() {
return utils.tryWrapperForImpl(this[impl].onstorage);
},
set(V) {
this[impl].onstorage = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onunhandledrejection", {
get() {
return utils.tryWrapperForImpl(this[impl].onunhandledrejection);
},
set(V) {
this[impl].onunhandledrejection = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WindowEventHandlers.prototype, "onunload", {
get() {
return utils.tryWrapperForImpl(this[impl].onunload);
},
set(V) {
this[impl].onunload = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(WindowEventHandlers.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(WindowEventHandlers.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: WindowEventHandlers,
expose: {
Window: { WindowEventHandlers: WindowEventHandlers }
}
};
module.exports = iface;
const Impl = require("../nodes/WindowEventHandlers-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Document = require("./Document.js");
const impl = utils.implSymbol;
function XMLDocument() {
throw new TypeError("Illegal constructor");
}
XMLDocument.prototype = Object.create(Document.interface.prototype);
XMLDocument.prototype.constructor = XMLDocument;
XMLDocument.prototype.toString = function () {
if (this === XMLDocument.prototype) {
return "[object XMLDocumentPrototype]";
}
return Document.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(XMLDocument.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(XMLDocument.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Document._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: XMLDocument,
expose: {
Window: { XMLDocument: XMLDocument }
}
};
module.exports = iface;
const Impl = require("../nodes/XMLDocument-impl.js");
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 1 43 43 356 70 286 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
module.exports.mixin = function mixin(target, source) {
const keys = Object.getOwnPropertyNames(source);
for (let i = 0; i < keys.length; ++i) {
if (keys[i] in target) {
continue;
}
Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i]));
}
};
const wrapperSymbol = Symbol("wrapper");
const implSymbol = Symbol("impl");
function wrapperForImpl(impl) {
return impl ? impl[wrapperSymbol] : null;
};
function implForWrapper(wrapper) {
return wrapper ? wrapper[implSymbol] : null;
};
function tryWrapperForImpl(impl) {
const wrapper = wrapperForImpl(impl);
return wrapper ? wrapper : impl;
};
function tryImplForWrapper(wrapper) {
const impl = implForWrapper(wrapper);
return impl ? impl : wrapper;
};
const iterInternalSymbol = Symbol("internal");
const IteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));
module.exports.wrapperSymbol = wrapperSymbol;
module.exports.implSymbol = implSymbol;
module.exports.wrapperForImpl = wrapperForImpl;
module.exports.implForWrapper = implForWrapper;
module.exports.tryWrapperForImpl = tryWrapperForImpl;
module.exports.tryImplForWrapper = tryImplForWrapper;
module.exports.iterInternalSymbol = iterInternalSymbol;
module.exports.IteratorPrototype = IteratorPrototype;
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| document-base-url.js | 33.33% | (7 / 21) | 0% | (0 / 9) | 0% | (0 / 1) | 33.33% | (7 / 21) | |
| focusing.js | 24.14% | (7 / 29) | 0% | (0 / 28) | 100% | (0 / 0) | 24.14% | (7 / 29) | |
| form-controls.js | 26.32% | (5 / 19) | 0% | (0 / 21) | 100% | (0 / 0) | 26.32% | (5 / 19) | |
| internal-constants.js | 100% | (4 / 4) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (4 / 4) | |
| ordered-set-parser.js | 50% | (1 / 2) | 100% | (0 / 0) | 0% | (0 / 1) | 50% | (1 / 2) | |
| proxied-window-event-handlers.js | 100% | (1 / 1) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (1 / 1) | |
| runtime-script-errors.js | 19.35% | (6 / 31) | 0% | (0 / 27) | 0% | (0 / 3) | 19.35% | (6 / 31) | |
| selectors.js | 38.46% | (5 / 13) | 0% | (0 / 7) | 0% | (0 / 2) | 38.46% | (5 / 13) | |
| strings.js | 50% | (1 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 50% | (1 / 2) | |
| stylesheets.js | 18.18% | (8 / 44) | 0% | (0 / 16) | 0% | (0 / 2) | 18.18% | (8 / 44) | |
| traversal.js | 24.32% | (9 / 37) | 0% | (0 / 24) | 0% | (0 / 4) | 24.32% | (9 / 37) | |
| validate-names.js | 16.67% | (5 / 30) | 0% | (0 / 26) | 0% | (0 / 3) | 16.67% | (5 / 30) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 1 1 1 1 1 1 1 | "use strict";
const internalQuerySelector = require("./selectors").querySelector;
const whatwgURL = require("whatwg-url");
exports.documentBaseURL = document => {
// https://html.spec.whatwg.org/multipage/infrastructure.html#document-base-url
const firstBase = internalQuerySelector(document, "base[href]");
const fallbackBaseURL = exports.fallbackBaseURL(document);
if (firstBase === null) {
return fallbackBaseURL;
}
return frozenBaseURL(firstBase, fallbackBaseURL);
};
exports.documentBaseURLSerialized = document => {
return whatwgURL.serializeURL(exports.documentBaseURL(document));
};
exports.fallbackBaseURL = document => {
// https://html.spec.whatwg.org/multipage/infrastructure.html#fallback-base-url
// Unimplemented: <iframe srcdoc>
if (document.URL === "about:blank" && document._defaultView &&
document._defaultView._parent !== document._defaultView) {
return exports.documentBaseURL(document._defaultView._parent._document);
}
return document._URL;
};
exports.parseURLToResultingURLRecord = (url, document) => {
// https://html.spec.whatwg.org/#resolve-a-url
// Encoding stuff ignored; always UTF-8 for us, for now.
const baseURL = exports.documentBaseURL(document);
return whatwgURL.parseURL(url, { baseURL });
// This returns the resulting URL record; to get the resulting URL string, just serialize it.
};
function frozenBaseURL(baseElement, fallbackBaseURL) {
// https://html.spec.whatwg.org/multipage/semantics.html#frozen-base-url
// The spec is eager (setting the frozen base URL when things change); we are lazy (getting it when we need to)
const baseHrefAttribute = baseElement.getAttribute("href");
const result = whatwgURL.parseURL(baseHrefAttribute, { baseURL: fallbackBaseURL });
return result === "failure" ? fallbackBaseURL : result;
}
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | 1 1 1 1 1 1 1 | "use strict";
const nodeType = require("../node-type.js");
const FocusEvent = require("../generated/FocusEvent.js");
const idlUtils = require("../generated/utils.js");
const isDisabled = require("./form-controls.js").isDisabled;
const focusableFormElements = new Set(["input", "select", "textarea", "button"]);
// https://html.spec.whatwg.org/multipage/interaction.html#focusable-area, but also some of
// https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps: e.g., Documents are not actually focusable
// areas, but their viewports are, and the first step of the latter algorithm translates Documents to their viewports.
// And also https://html.spec.whatwg.org/multipage/interaction.html#specially-focusable!
exports.isFocusableAreaElement = elImpl => {
if (!elImpl._ownerDocument._defaultView && !elImpl._defaultView) {
return false;
}
if (elImpl._nodeType === nodeType.DOCUMENT_NODE) {
return true;
}
if (!Number.isNaN(parseInt(elImpl.getAttribute("tabindex")))) {
return true;
}
if (elImpl._namespaceURI === "http://www.w3.org/1999/xhtml") {
if (elImpl._localName === "iframe") {
return true;
}
if (elImpl._localName === "a" && elImpl.hasAttribute("href")) {
return true;
}
if (focusableFormElements.has(elImpl._localName) && !isDisabled(elImpl)) {
if (elImpl._localName === "input" && elImpl.type === "hidden") {
return false;
}
return true;
}
}
return false;
};
// https://html.spec.whatwg.org/multipage/interaction.html#fire-a-focus-event plus the steps of
// https://html.spec.whatwg.org/multipage/interaction.html#focus-update-steps that adjust Documents to Windows
exports.fireFocusEventWithTargetAdjustment = (name, target, relatedTarget) => {
if (target === null) {
// E.g. firing blur with nothing previously focused.
return;
}
const event = FocusEvent.createImpl(
[name, {
bubbles: false,
cancelable: false,
relatedTarget,
view: target._ownerDocument._defaultView,
detail: 0
}],
{
isTrusted: true
}
);
if (target._defaultView) {
target = idlUtils.implForWrapper(target._defaultView);
}
// _dispatch allows setting isTrusted
target._dispatch(event);
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 1 1 1 1 1 | "use strict";
const submittableLocalNames = new Set(["button", "input", "keygen", "object", "select", "textarea"]);
exports.isDisabled = formControl => {
if (formControl.localName === "button" || formControl.localName === "input" || formControl.localName === "select" ||
formControl.localName === "textarea") {
if (formControl.hasAttribute("disabled")) {
return true;
}
}
let e = formControl.parentNode;
while (e) {
if (e.localName === "fieldset" && e.hasAttribute("disabled")) {
const firstLegendElementChild = e.querySelector("legend");
if (!firstLegendElementChild || !firstLegendElementChild.contains(formControl)) {
return true;
}
}
e = e.parentNode;
}
return false;
};
exports.isSubmittable = formControl => {
// https://html.spec.whatwg.org/multipage/forms.html#category-submit
return submittableLocalNames.has(formControl.localName);
};
exports.isButton = formControl => {
// https://html.spec.whatwg.org/multipage/forms.html#concept-button
return formControl.type === "button" || formControl.type === "submit" || formControl.type === "reset" ||
formControl.type === "image" || formControl.localName === "button";
};
exports.normalizeToCRLF = string => {
return string.replace(/\r([^\n])/g, "\r\n$1")
.replace(/\r$/, "\r\n")
.replace(/([^\r])\n/g, "$1\r\n")
.replace(/^\n/, "\r\n");
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 1 1 1 1 | "use strict";
const SymbolTree = require("symbol-tree");
exports.cloningSteps = Symbol("cloning steps");
exports.locationInfo = Symbol("location info");
// TODO: the many underscore-prefixed hooks should move here
// E.g. _attrModified (which maybe should be split into its per-spec variants)
/**
* This SymbolTree is used to build the tree for all Node in a document
*/
exports.domSymbolTree = new SymbolTree("DOM SymbolTree");
|
| 1 2 3 4 5 6 7 | 1 | "use strict"; module.exports = function orderedSetParser(input) { return new Set(input.split(/[\t\n\f\r ]+/).filter(Boolean)); }; |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 | "use strict"; // https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers-on-elements,-document-objects,-and-window-objects module.exports = new Set(["onblur", "onerror", "onfocus", "onload", "onresize", "onscroll", "onafterprint", "onbeforeprint", "onbeforeunload", "onhashchange", "onlanguagechange", "onmessage", "onoffline", "ononline", "onpagehide", "onpageshow", "onpopstate", "onstorage", "onunload"]); // level2/html sets up setters/getters on HTMLBodyElement that proxy to the window (setting data properties there) // level1/core sets up so that modifying the appropriate attributes on body elements will forward to setting on // the window, with the appropriate `this`. |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 1 1 1 1 1 1 | "use strict";
const util = require("util");
const ErrorEvent = require("../generated/ErrorEvent");
const errorReportingMode = Symbol("error reporting mode");
// https://html.spec.whatwg.org/multipage/webappapis.html#report-the-error
// Omits script parameter and any check for muted errors; takes error object, message, and location as params, unlike
// the spec. Returns whether the event was handled or not.
function reportAnError(line, col, target, errorObject, message, location) {
if (target[errorReportingMode]) {
return false;
}
target[errorReportingMode] = true;
// TODO Events: use constructor directly, once they are no longer tied to a window.
const event = ErrorEvent.createImpl(["error", {
bubbles: false,
cancelable: true,
message,
filename: location,
lineno: line,
colno: col,
error: errorObject
}]);
try {
target.dispatchEvent(event);
} finally {
target[errorReportingMode] = false;
return event.defaultPrevented;
}
}
module.exports = function reportException(window, error, filenameHint) {
// This function will give good results on real Error objects with stacks; poor ones otherwise
const stack = error && error.stack;
const lines = stack && stack.split("\n");
// Find the first line that matches; important for multi-line messages
let pieces;
if (lines) {
for (let i = 1; i < lines.length && !pieces; ++i) {
pieces = lines[i].match(/at (?:(.+)\s+)?\(?(?:(.+?):(\d+):(\d+)|([^)]+))\)?/);
}
}
const fileName = pieces && pieces[2] || filenameHint || window._document.URL;
const lineNumber = pieces && parseInt(pieces[3]) || 0;
const columnNumber = pieces && parseInt(pieces[4]) || 0;
const handled = reportAnError(lineNumber, columnNumber, window, error, error.message, fileName);
if (!handled) {
const errorString = shouldBeDisplayedAsError(error) ? `[${error.name}: ${error.message}]` : util.inspect(error);
const jsdomError = new Error(`Uncaught ${errorString}`);
jsdomError.detail = error;
jsdomError.type = "unhandled exception";
window._virtualConsole.emit("jsdomError", jsdomError);
}
};
function shouldBeDisplayedAsError(x) {
return x.name && x.message !== undefined && x.stack;
}
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 1 1 1 1 1 | "use strict";
const idlUtils = require("../generated/utils");
const nwmatcher = require("nwmatcher/src/nwmatcher-noqsa");
const domSymbolTree = require("./internal-constants").domSymbolTree;
// Internal method so you don't have to go through the public API
exports.querySelector = function (parentNode, selectors) {
if (!domSymbolTree.hasChildren(parentNode) ||
(parentNode === parentNode._ownerDocument && !parentNode.documentElement)) {
// This allows us to avoid the explosion that occurs if you try to add nwmatcher to a document that is not yet
// initialized.
return null;
}
return addNwmatcher(parentNode).first(selectors, idlUtils.wrapperForImpl(parentNode));
};
// nwmatcher gets `document.documentElement` at creation-time, so we have to initialize lazily, since in the initial
// stages of Document initialization, there is no documentElement present yet.
function addNwmatcher(parentNode) {
const document = parentNode._ownerDocument;
if (!document._nwmatcher) {
document._nwmatcher = nwmatcher({ document });
document._nwmatcher.configure({ UNIQUE_ID: false });
}
return document._nwmatcher;
}
|
| 1 2 3 4 5 6 7 8 | 1 | "use strict";
// https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
exports.stripAndCollapseASCIIWhitespace = s => {
return s.replace(/[ \t\n\f\r]+/g, " ").replace(/^[ \t\n\f\r]+/, "").replace(/[ \t\n\f\r]+$/, "");
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 1 1 1 1 1 1 1 1 | "use strict";
const cssom = require("cssom");
const whatwgEncoding = require("whatwg-encoding");
const whatwgURL = require("whatwg-url");
const resourceLoader = require("../../browser/resource-loader");
exports.fetchStylesheet = (elementImpl, urlString, sheet) => {
const parsedURL = whatwgURL.parseURL(urlString);
return fetchStylesheetInternal(elementImpl, urlString, parsedURL, sheet);
};
exports.evaluateStylesheet = (elementImpl, data, sheet, baseURL) => {
let newStyleSheet;
try {
newStyleSheet = cssom.parse(data);
} catch (e) {
if (elementImpl._ownerDocument._defaultView) {
const error = new Error("Could not parse CSS stylesheet");
error.detail = data;
error.type = "css parsing";
elementImpl._ownerDocument._defaultView._virtualConsole.emit("jsdomError", error);
}
elementImpl._ownerDocument.styleSheets.push(sheet);
return;
}
const spliceArgs = newStyleSheet.cssRules;
spliceArgs.unshift(0, sheet.cssRules.length);
Array.prototype.splice.apply(sheet.cssRules, spliceArgs);
scanForImportRules(elementImpl, sheet.cssRules, baseURL);
elementImpl._ownerDocument.styleSheets.push(sheet);
};
function fetchStylesheetInternal(elementImpl, urlString, parsedURL, sheet) {
let defaultEncoding = elementImpl._ownerDocument._encoding;
if (elementImpl.localName === "link" && elementImpl.hasAttribute("charset")) {
defaultEncoding = whatwgEncoding.labelToName(elementImpl.getAttribute("charset"));
}
resourceLoader.load(elementImpl, urlString, { defaultEncoding }, data => {
// TODO: MIME type checking?
exports.evaluateStylesheet(elementImpl, data, sheet, parsedURL);
});
}
function scanForImportRules(elementImpl, cssRules, baseURL) {
if (!cssRules) {
return;
}
for (let i = 0; i < cssRules.length; ++i) {
if (cssRules[i].cssRules) {
// @media rule: keep searching inside it.
scanForImportRules(elementImpl, cssRules[i].cssRules, baseURL);
} else if (cssRules[i].href) {
// @import rule: fetch the resource and evaluate it.
// See http://dev.w3.org/csswg/cssom/#css-import-rule
// If loading of the style sheet fails its cssRules list is simply
// empty. I.e. an @import rule always has an associated style sheet.
const parsed = whatwgURL.parseURL(cssRules[i].href, { baseURL });
if (parsed === "failure") {
const window = elementImpl._ownerDocument._defaultView;
if (window) {
const error = new Error(`Could not parse CSS @import URL ${cssRules[i].href} relative to base URL ` +
`"${whatwgURL.serializeURL(baseURL)}"`);
error.type = "css @import URL parsing";
window._virtualConsole.emit("jsdomError", error);
}
} else {
fetchStylesheetInternal(elementImpl, whatwgURL.serializeURL(parsed), parsed, elementImpl.sheet);
}
}
}
}
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 1 1 1 1 1 1 1 1 1 | "use strict";
const domSymbolTree = require("./internal-constants").domSymbolTree;
// All these operate on and return impls, not wrappers!
exports.closest = (e, localName) => {
while (e) {
if (e.localName === localName) {
return e;
}
e = domSymbolTree.parent(e);
}
return null;
};
exports.childrenByHTMLLocalName = (parent, localName) => {
return domSymbolTree.childrenToArray(parent, { filter(node) {
return node._localName === localName && node._namespaceURI === "http://www.w3.org/1999/xhtml";
} });
};
exports.descendantsByHTMLLocalName = (parent, localName) => {
return domSymbolTree.treeToArray(parent, { filter(node) {
return node._localName === localName && node._namespaceURI === "http://www.w3.org/1999/xhtml" && node !== parent;
} });
};
exports.childrenByHTMLLocalNames = (parent, localNamesSet) => {
return domSymbolTree.childrenToArray(parent, { filter(node) {
return localNamesSet.has(node._localName) && node._namespaceURI === "http://www.w3.org/1999/xhtml";
} });
};
exports.descendantsByHTMLLocalNames = (parent, localNamesSet) => {
return domSymbolTree.treeToArray(parent, { filter(node) {
return localNamesSet.has(node._localName) &&
node._namespaceURI === "http://www.w3.org/1999/xhtml" &&
node !== parent;
} });
};
exports.firstChildWithHTMLLocalName = (parent, localName) => {
const iterator = domSymbolTree.childrenIterator(parent);
for (const child of iterator) {
if (child._localName === localName && child._namespaceURI === "http://www.w3.org/1999/xhtml") {
return child;
}
}
return null;
};
exports.firstChildWithHTMLLocalNames = (parent, localNamesSet) => {
const iterator = domSymbolTree.childrenIterator(parent);
for (const child of iterator) {
if (localNamesSet.has(child._localName) && child._namespaceURI === "http://www.w3.org/1999/xhtml") {
return child;
}
}
return null;
};
exports.firstDescendantWithHTMLLocalName = (parent, localName) => {
const iterator = domSymbolTree.treeIterator(parent);
for (const descendant of iterator) {
if (descendant._localName === localName && descendant._namespaceURI === "http://www.w3.org/1999/xhtml") {
return descendant;
}
}
return null;
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 1 1 1 1 1 | "use strict";
const xnv = require("xml-name-validator");
const DOMException = require("../../web-idl/DOMException");
// https://dom.spec.whatwg.org/#validate
exports.name = function (name) {
const result = xnv.name(name);
if (!result.success) {
throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
"\"" + name + "\" did not match the Name production: " + result.error);
}
};
exports.qname = function (qname) {
exports.name(qname);
const result = xnv.qname(qname);
if (!result.success) {
throw new DOMException(DOMException.NAMESPACE_ERR,
"\"" + qname + "\" did not match the QName production: " + result.error);
}
};
exports.validateAndExtract = function (namespace, qualifiedName) {
if (namespace === "") {
namespace = null;
}
exports.qname(qualifiedName);
let prefix = null;
let localName = qualifiedName;
const colonIndex = qualifiedName.indexOf(":");
if (colonIndex !== -1) {
prefix = qualifiedName.substring(0, colonIndex);
localName = qualifiedName.substring(colonIndex + 1);
}
if (prefix !== null && namespace === null) {
throw new DOMException(DOMException.NAMESPACE_ERR,
"A namespace was given but a prefix was also extracted from the qualifiedName");
}
if (prefix === "xml" && namespace !== "http://www.w3.org/XML/1998/namespace") {
throw new DOMException(DOMException.NAMESPACE_ERR,
"A prefix of \"xml\" was given but the namespace was not the XML namespace");
}
if ((qualifiedName === "xmlns" || prefix === "xmlns") && namespace !== "http://www.w3.org/2000/xmlns/") {
throw new DOMException(DOMException.NAMESPACE_ERR,
"A prefix or qualifiedName of \"xmlns\" was given but the namespace was not the XMLNS namespace");
}
if (namespace === "http://www.w3.org/2000/xmlns/" && qualifiedName !== "xmlns" && prefix !== "xmlns") {
throw new DOMException(DOMException.NAMESPACE_ERR,
"The XMLNS namespace was given but neither the prefix nor qualifiedName was \"xmlns\"");
}
return { namespace, prefix, localName };
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| Navigator-impl.js | 87.5% | (14 / 16) | 100% | (0 / 0) | 0% | (0 / 1) | 87.5% | (14 / 16) | |
| NavigatorConcurrentHardware-impl.js | 66.67% | (2 / 3) | 100% | (0 / 0) | 0% | (0 / 1) | 66.67% | (2 / 3) | |
| NavigatorCookies-impl.js | 50% | (1 / 2) | 100% | (0 / 0) | 0% | (0 / 1) | 50% | (1 / 2) | |
| NavigatorID-impl.js | 11.11% | (1 / 9) | 100% | (0 / 0) | 0% | (0 / 8) | 11.11% | (1 / 9) | |
| NavigatorLanguage-impl.js | 50% | (1 / 2) | 100% | (0 / 0) | 0% | (0 / 1) | 50% | (1 / 2) | |
| NavigatorOnLine-impl.js | 50% | (1 / 2) | 100% | (0 / 0) | 0% | (0 / 1) | 50% | (1 / 2) | |
| NavigatorPlugins-impl.js | 50% | (1 / 2) | 100% | (0 / 0) | 0% | (0 / 1) | 50% | (1 / 2) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const idlUtils = require("../generated/utils");
const NavigatorIDImpl = require("./NavigatorID-impl").implementation;
const NavigatorLanguageImpl = require("./NavigatorLanguage-impl").implementation;
const NavigatorOnLineImpl = require("./NavigatorOnLine-impl").implementation;
const NavigatorCookiesImpl = require("./NavigatorCookies-impl").implementation;
const NavigatorPluginsImpl = require("./NavigatorPlugins-impl").implementation;
const NavigatorConcurrentHardwareImpl = require("./NavigatorConcurrentHardware-impl").implementation;
class NavigatorImpl {
constructor(args, privateData) {
this.userAgent = privateData.userAgent;
this.languages = Object.freeze(["en-US", "en"]);
}
}
idlUtils.mixin(NavigatorImpl.prototype, NavigatorIDImpl.prototype);
idlUtils.mixin(NavigatorImpl.prototype, NavigatorLanguageImpl.prototype);
idlUtils.mixin(NavigatorImpl.prototype, NavigatorOnLineImpl.prototype);
idlUtils.mixin(NavigatorImpl.prototype, NavigatorCookiesImpl.prototype);
idlUtils.mixin(NavigatorImpl.prototype, NavigatorPluginsImpl.prototype);
idlUtils.mixin(NavigatorImpl.prototype, NavigatorConcurrentHardwareImpl.prototype);
exports.implementation = NavigatorImpl;
|
| 1 2 3 4 5 6 7 8 9 10 | 1 1 | "use strict";
const os = require("os");
exports.implementation = class NavigatorConcurrentHardwareImpl {
get hardwareConcurrency() {
return os.cpus().length;
}
};
|
| 1 2 3 4 5 6 7 8 9 | 1 | "use strict";
exports.implementation = class NavigatorCookiesImpl {
get cookieEnabled() {
return true;
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 1 | "use strict";
exports.implementation = class NavigatorIDImpl {
get appCodeName() {
return "Mozilla";
}
get appName() {
return "Netscape";
}
get appVersion() {
return "4.0";
}
get platform() {
return "";
}
get product() {
return "Gecko";
}
get productSub() {
return "20030107";
}
// see Navigator constructor for userAgent
get vendor() {
return "Apple Computer, Inc.";
}
get vendorSub() {
return "";
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 | "use strict";
exports.implementation = class NavigatorLanguageImpl {
get language() {
return "en-US";
}
// See Navigator constructor for languages
};
|
| 1 2 3 4 5 6 7 8 9 | 1 | "use strict";
exports.implementation = class NavigatorOnLineImpl {
get onLine() {
return true;
}
};
|
| 1 2 3 4 5 6 7 8 9 | 1 | "use strict";
exports.implementation = class NavigatorPluginsImpl {
javaEnabled() {
return false;
}
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| CDATASection-impl.js | 60% | (3 / 5) | 100% | (0 / 0) | 0% | (0 / 1) | 60% | (3 / 5) | |
| CharacterData-impl.js | 26.67% | (8 / 30) | 0% | (0 / 8) | 0% | (0 / 9) | 26.67% | (8 / 30) | |
| ChildNode-impl.js | 25% | (1 / 4) | 0% | (0 / 2) | 0% | (0 / 1) | 25% | (1 / 4) | |
| Comment-impl.js | 60% | (3 / 5) | 100% | (0 / 0) | 0% | (0 / 1) | 60% | (3 / 5) | |
| DOMImplementation-impl.js | 7.14% | (5 / 70) | 0% | (0 / 52) | 0% | (0 / 8) | 7.14% | (5 / 70) | |
| Document-impl.js | 15.92% | (60 / 377) | 0% | (0 / 170) | 0% | (0 / 84) | 16.04% | (60 / 374) | |
| DocumentFragment-impl.js | 75% | (6 / 8) | 100% | (0 / 0) | 0% | (0 / 1) | 75% | (6 / 8) | |
| DocumentType-impl.js | 54.55% | (6 / 11) | 100% | (0 / 0) | 0% | (0 / 1) | 54.55% | (6 / 11) | |
| Element-impl.js | 15.81% | (37 / 234) | 0% | (0 / 119) | 0% | (0 / 50) | 15.81% | (37 / 234) | |
| ElementCSSInlineStyle-impl.js | 100% | (1 / 1) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (1 / 1) | |
| ElementContentEditable-impl.js | 100% | (1 / 1) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (1 / 1) | |
| GlobalEventHandlers-impl.js | 100% | (1 / 1) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (1 / 1) | |
| HTMLAnchorElement-impl.js | 55.56% | (5 / 9) | 100% | (0 / 0) | 0% | (0 / 3) | 55.56% | (5 / 9) | |
| HTMLAppletElement-impl.js | 42.86% | (3 / 7) | 100% | (0 / 0) | 0% | (0 / 4) | 42.86% | (3 / 7) | |
| HTMLAreaElement-impl.js | 71.43% | (5 / 7) | 100% | (0 / 0) | 0% | (0 / 1) | 71.43% | (5 / 7) | |
| HTMLAudioElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLBRElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLBaseElement-impl.js | 36.36% | (4 / 11) | 0% | (0 / 4) | 0% | (0 / 2) | 36.36% | (4 / 11) | |
| HTMLBodyElement-impl.js | 50% | (5 / 10) | 0% | (0 / 4) | 0% | (0 / 2) | 50% | (5 / 10) | |
| HTMLButtonElement-impl.js | 19.05% | (4 / 21) | 0% | (0 / 20) | 0% | (0 / 5) | 19.05% | (4 / 21) | |
| HTMLCanvasElement-impl.js | 10% | (6 / 60) | 0% | (0 / 44) | 0% | (0 / 13) | 10% | (6 / 60) | |
| HTMLDListElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLDataElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLDataListElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLDialogElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLDirectoryElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLDivElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLElement-impl.js | 10.77% | (7 / 65) | 0% | (0 / 37) | 0% | (0 / 16) | 10.77% | (7 / 65) | |
| HTMLEmbedElement-impl.js | 60% | (3 / 5) | 100% | (0 / 0) | 0% | (0 / 2) | 60% | (3 / 5) | |
| HTMLFieldSetElement-impl.js | 75% | (3 / 4) | 100% | (0 / 0) | 0% | (0 / 1) | 75% | (3 / 4) | |
| HTMLFontElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLFormElement-impl.js | 21.57% | (11 / 51) | 0% | (0 / 20) | 0% | (0 / 13) | 22% | (11 / 50) | |
| HTMLFrameElement-impl.js | 15.85% | (13 / 82) | 0% | (0 / 36) | 0% | (0 / 12) | 16.05% | (13 / 81) | |
| HTMLFrameSetElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLHRElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLHeadElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLHeadingElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLHtmlElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLHyperlinkElementUtils-impl.js | 3.85% | (5 / 130) | 0% | (0 / 90) | 0% | (0 / 25) | 3.85% | (5 / 130) | |
| HTMLIFrameElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLImageElement-impl.js | 16.67% | (6 / 36) | 0% | (0 / 29) | 0% | (0 / 13) | 16.67% | (6 / 36) | |
| HTMLInputElement-impl.js | 7.88% | (16 / 203) | 0% | (0 / 124) | 0% | (0 / 38) | 7.88% | (16 / 203) | |
| HTMLLIElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLLabelElement-impl.js | 30.43% | (7 / 23) | 0% | (0 / 20) | 0% | (0 / 4) | 30.43% | (7 / 23) | |
| HTMLLegendElement-impl.js | 75% | (3 / 4) | 100% | (0 / 0) | 0% | (0 / 1) | 75% | (3 / 4) | |
| HTMLLinkElement-impl.js | 34.38% | (11 / 32) | 0% | (0 / 15) | 0% | (0 / 7) | 34.38% | (11 / 32) | |
| HTMLMapElement-impl.js | 66.67% | (2 / 3) | 100% | (0 / 0) | 0% | (0 / 1) | 66.67% | (2 / 3) | |
| HTMLMediaElement-impl.js | 8.96% | (6 / 67) | 0% | (0 / 20) | 0% | (0 / 23) | 8.96% | (6 / 67) | |
| HTMLMenuElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLMetaElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLMeterElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLModElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLOListElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLObjectElement-impl.js | 40% | (4 / 10) | 100% | (0 / 0) | 0% | (0 / 6) | 40% | (4 / 10) | |
| HTMLOptGroupElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLOptionElement-impl.js | 10.34% | (6 / 58) | 0% | (0 / 34) | 0% | (0 / 15) | 10.34% | (6 / 58) | |
| HTMLOutputElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLParagraphElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLParamElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLPreElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLProgressElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLQuoteElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLScriptElement-impl.js | 20.75% | (11 / 53) | 0% | (0 / 38) | 0% | (0 / 9) | 20.75% | (11 / 53) | |
| HTMLSelectElement-impl.js | 11.25% | (9 / 80) | 0% | (0 / 48) | 0% | (0 / 17) | 11.39% | (9 / 79) | |
| HTMLSourceElement-impl.js | 60% | (3 / 5) | 100% | (0 / 0) | 0% | (0 / 2) | 60% | (3 / 5) | |
| HTMLSpanElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLStyleElement-impl.js | 52.94% | (9 / 17) | 0% | (0 / 6) | 0% | (0 / 1) | 52.94% | (9 / 17) | |
| HTMLTableCaptionElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLTableCellElement-impl.js | 27.27% | (6 / 22) | 0% | (0 / 12) | 0% | (0 / 7) | 27.27% | (6 / 22) | |
| HTMLTableColElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLTableDataCellElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLTableElement-impl.js | 9.21% | (7 / 76) | 0% | (0 / 42) | 0% | (0 / 13) | 9.33% | (7 / 75) | |
| HTMLTableHeaderCellElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLTableRowElement-impl.js | 23.68% | (9 / 38) | 0% | (0 / 22) | 0% | (0 / 5) | 24.32% | (9 / 37) | |
| HTMLTableSectionElement-impl.js | 23.08% | (6 / 26) | 0% | (0 / 18) | 0% | (0 / 3) | 24% | (6 / 25) | |
| HTMLTemplateElement-impl.js | 38.46% | (5 / 13) | 0% | (0 / 2) | 0% | (0 / 3) | 38.46% | (5 / 13) | |
| HTMLTextAreaElement-impl.js | 5.95% | (5 / 84) | 0% | (0 / 34) | 0% | (0 / 27) | 5.95% | (5 / 84) | |
| HTMLTimeElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLTitleElement-impl.js | 50% | (2 / 4) | 100% | (0 / 0) | 0% | (0 / 2) | 50% | (2 / 4) | |
| HTMLTrackElement-impl.js | 50% | (3 / 6) | 100% | (0 / 0) | 0% | (0 / 3) | 50% | (3 / 6) | |
| HTMLUListElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLUnknownElement-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) | |
| HTMLVideoElement-impl.js | 42.86% | (3 / 7) | 100% | (0 / 0) | 0% | (0 / 4) | 42.86% | (3 / 7) | |
| LinkStyle-impl.js | 40% | (2 / 5) | 0% | (0 / 2) | 0% | (0 / 1) | 40% | (2 / 5) | |
| Node-impl.js | 7.58% | (16 / 211) | 0% | (0 / 179) | 0% | (0 / 34) | 7.62% | (16 / 210) | |
| NonDocumentTypeChildNode-impl.js | 27.27% | (3 / 11) | 0% | (0 / 4) | 0% | (0 / 2) | 27.27% | (3 / 11) | |
| NonElementParentNode-impl.js | 100% | (1 / 1) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (1 / 1) | |
| ParentNode-impl.js | 30.23% | (13 / 43) | 0% | (0 / 8) | 0% | (0 / 8) | 30.23% | (13 / 43) | |
| ProcessingInstruction-impl.js | 42.86% | (3 / 7) | 100% | (0 / 0) | 0% | (0 / 2) | 42.86% | (3 / 7) | |
| Text-impl.js | 16.67% | (5 / 30) | 0% | (0 / 8) | 0% | (0 / 3) | 16.67% | (5 / 30) | |
| WindowEventHandlers-impl.js | 100% | (1 / 1) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (1 / 1) | |
| XMLDocument-impl.js | 100% | (2 / 2) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (2 / 2) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1 1 1 | "use strict";
const TextImpl = require("./Text-impl").implementation;
const NODE_TYPE = require("../node-type");
class CDATASectionImpl extends TextImpl {
constructor(args, privateData) {
super(args, privateData);
this.nodeType = NODE_TYPE.CDATA_SECTION_NODE;
}
}
module.exports = {
implementation: CDATASectionImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 1 1 1 1 1 1 1 1 | "use strict";
const idlUtils = require("../generated/utils");
const NodeImpl = require("./Node-impl").implementation;
const ChildNodeImpl = require("./ChildNode-impl").implementation;
const NonDocumentTypeChildNodeImpl = require("./NonDocumentTypeChildNode-impl").implementation;
const DOMException = require("../../web-idl/DOMException");
class CharacterDataImpl extends NodeImpl {
constructor(args, privateData) {
super(args, privateData);
this._data = privateData.data;
}
get data() {
return this._data;
}
set data(data) {
this._data = data;
}
get length() {
return this._data.length;
}
substringData(offset, count) {
const length = this.length;
if (offset > length) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
if (offset + count > length) {
return this._data.substring(offset);
}
return this._data.substring(offset, offset + count);
}
appendData(data) {
this.replaceData(this.length, 0, data);
}
insertData(offset, data) {
this.replaceData(offset, 0, data);
}
deleteData(offset, count) {
this.replaceData(offset, count, "");
}
replaceData(offset, count, data) {
const length = this.length;
if (offset > length) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
if (offset + count > length) {
count = length - offset;
}
const start = this._data.substring(0, offset);
const end = this._data.substring(offset + count);
this._data = start + data + end;
// TODO: range stuff
}
}
idlUtils.mixin(CharacterDataImpl.prototype, NonDocumentTypeChildNodeImpl.prototype);
idlUtils.mixin(CharacterDataImpl.prototype, ChildNodeImpl.prototype);
module.exports = {
implementation: CharacterDataImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 1 | "use strict";
class ChildNodeImpl {
remove() {
if (!this.parentNode) {
return;
}
this.parentNode.removeChild(this);
}
}
module.exports = {
implementation: ChildNodeImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1 1 1 | "use strict";
const CharacterDataImpl = require("./CharacterData-impl").implementation;
const NODE_TYPE = require("../node-type");
class CommentImpl extends CharacterDataImpl {
constructor(args, privateData) {
super(args, privateData);
this.nodeType = NODE_TYPE.COMMENT_NODE;
}
}
module.exports = {
implementation: CommentImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | 1 1 1 1 1 | "use strict";
const vm = require("vm");
const validateNames = require("../helpers/validate-names");
const DocumentType = require("../generated/DocumentType");
const Document = require("../generated/Document");
class DOMImplementationImpl {
constructor(args, privateData) {
this.core = privateData.core;
this._ownerDocument = privateData.ownerDocument;
this._features = Object.create(null);
}
hasFeature() {
return true;
}
createDocumentType(qualifiedName, publicId, systemId) {
validateNames.qname(qualifiedName);
return DocumentType.createImpl([], {
core: this.core,
ownerDocument: this._ownerDocument,
name: qualifiedName,
publicId,
systemId
});
}
createDocument(namespace, qualifiedName, doctype) {
namespace = namespace !== null ? String(namespace) : namespace;
qualifiedName = qualifiedName === null ? "" : String(qualifiedName);
if (doctype === undefined) {
doctype = null;
}
const document = Document.createImpl([], {
core: this.core,
options: { parsingMode: "xml", encoding: "UTF-8" }
});
let element = null;
if (qualifiedName !== "") {
element = document.createElementNS(namespace, qualifiedName);
}
if (doctype !== null) {
document.appendChild(doctype);
}
if (element !== null) {
document.appendChild(element);
}
return document;
}
createHTMLDocument(title) {
// Let doc be a new document that is an HTML document.
// Set doc's content type to "text/html".
const document = Document.createImpl([], {
core: this.core,
options: { parsingMode: "html", encoding: "UTF-8" }
});
// Create a doctype, with "html" as its name and with its node document set
// to doc. Append the newly created node to doc.
const doctype = DocumentType.createImpl([], {
core: this.core,
ownerDocument: this,
name: "html",
publicId: "",
systemId: ""
});
document.appendChild(doctype);
// Create an html element in the HTML namespace, and append it to doc.
const htmlElement = document.createElementNS("http://www.w3.org/1999/xhtml", "html");
document.appendChild(htmlElement);
// Create a head element in the HTML namespace, and append it to the html
// element created in the previous step.
const headElement = document.createElement("head");
htmlElement.appendChild(headElement);
// If the title argument is not omitted:
if (title !== undefined) {
// Create a title element in the HTML namespace, and append it to the head
// element created in the previous step.
const titleElement = document.createElement("title");
headElement.appendChild(titleElement);
// Create a Text node, set its data to title (which could be the empty
// string), and append it to the title element created in the previous step.
titleElement.appendChild(document.createTextNode(title));
}
// Create a body element in the HTML namespace, and append it to the html
// element created in the earlier step.
htmlElement.appendChild(document.createElement("body"));
// doc's origin is an alias to the origin of the context object's associated
// document, and doc's effective script origin is an alias to the effective
// script origin of the context object's associated document.
return document;
}
_removeFeature(feature, version) {
feature = feature.toLowerCase();
if (this._features[feature]) {
if (version) {
const versions = this._features[feature];
for (let j = 0; j < versions.length; j++) {
if (versions[j] === version) {
versions.splice(j, 1);
return;
}
}
} else {
delete this._features[feature];
}
}
}
_addFeature(feature, version) {
feature = feature.toLowerCase();
if (version) {
if (!this._features[feature]) {
this._features[feature] = [];
}
if (version instanceof Array) {
Array.prototype.push.apply(this._features[feature], version);
} else {
this._features[feature].push(version);
}
if (feature === "processexternalresources" &&
(version === "script" || (version.indexOf && version.indexOf("script") !== -1)) &&
!vm.isContext(this._ownerDocument._global)) {
vm.createContext(this._ownerDocument._global);
this._ownerDocument._defaultView._globalProxy = vm.runInContext("this", this._ownerDocument._global);
this._ownerDocument._defaultView = this._ownerDocument._defaultView._globalProxy;
}
}
}
_hasFeature(feature, version) {
feature = feature ? feature.toLowerCase() : "";
const versions = this._features[feature] || false;
if (!version && versions.length && versions.length > 0) {
return true;
} else if (typeof versions === "string") {
return versions === version;
} else if (versions.indexOf && versions.length > 0) {
for (let i = 0; i < versions.length; i++) {
const found = versions[i] instanceof RegExp ? versions[i].test(version) : versions[i] === version;
if (found) {
return true;
}
}
return false;
}
return false;
}
}
module.exports = {
implementation: DOMImplementationImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const CookieJar = require("tough-cookie").CookieJar;
const NodeImpl = require("./Node-impl").implementation;
const isNodeImpl = require("../generated/Node").isImpl;
const NODE_TYPE = require("../node-type");
const memoizeQuery = require("../../utils").memoizeQuery;
const firstChildWithHTMLLocalName = require("../helpers/traversal").firstChildWithHTMLLocalName;
const firstChildWithHTMLLocalNames = require("../helpers/traversal").firstChildWithHTMLLocalNames;
const firstDescendantWithHTMLLocalName = require("../helpers/traversal").firstDescendantWithHTMLLocalName;
const whatwgURL = require("whatwg-url");
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const stripAndCollapseASCIIWhitespace = require("../helpers/strings").stripAndCollapseASCIIWhitespace;
const DOMException = require("../../web-idl/DOMException");
const HtmlToDom = require("../../browser/htmltodom").HtmlToDom;
const History = require("../generated/History");
const Location = require("../generated/Location");
const createHTMLCollection = require("../html-collection").create;
const idlUtils = require("../generated/utils");
const validateName = require("../helpers/validate-names").name;
const validateAndExtract = require("../helpers/validate-names").validateAndExtract;
const resourceLoader = require("../../browser/resource-loader");
const clone = require("../node").clone;
const generatedAttr = require("../generated/Attr");
const listOfElementsWithQualifiedName = require("../node").listOfElementsWithQualifiedName;
const listOfElementsWithNamespaceAndLocalName = require("../node").listOfElementsWithNamespaceAndLocalName;
const listOfElementsWithClassNames = require("../node").listOfElementsWithClassNames;
const Comment = require("../generated/Comment");
const ProcessingInstruction = require("../generated/ProcessingInstruction");
const CDATASection = require("../generated/CDATASection");
const Text = require("../generated/Text");
const DocumentFragment = require("../generated/DocumentFragment");
const DOMImplementation = require("../generated/DOMImplementation");
const ParentNodeImpl = require("./ParentNode-impl").implementation;
const HTMLElement = require("../generated/HTMLElement");
const HTMLUnknownElement = require("../generated/HTMLUnknownElement");
const TreeWalker = require("../generated/TreeWalker");
const CustomEvent = require("../generated/CustomEvent");
const ErrorEvent = require("../generated/ErrorEvent");
const Event = require("../generated/Event");
const FocusEvent = require("../generated/FocusEvent");
const HashChangeEvent = require("../generated/HashChangeEvent");
const KeyboardEvent = require("../generated/KeyboardEvent");
const MessageEvent = require("../generated/MessageEvent");
const MouseEvent = require("../generated/MouseEvent");
const PopStateEvent = require("../generated/PopStateEvent");
const ProgressEvent = require("../generated/ProgressEvent");
const TouchEvent = require("../generated/TouchEvent");
const UIEvent = require("../generated/UIEvent");
function clearChildNodes(node) {
for (let child = domSymbolTree.firstChild(node); child; child = domSymbolTree.firstChild(node)) {
node.removeChild(child);
}
}
function setInnerHTML(document, node, html) {
// Clear the children first:
if (node._templateContents) {
clearChildNodes(node._templateContents);
} else {
clearChildNodes(node);
}
if (html !== "") {
if (node.nodeName === "#document") {
document._htmlToDom.appendHtmlToDocument(html, node);
} else {
document._htmlToDom.appendHtmlToElement(html, node);
}
}
}
class ResourceQueue {
constructor(paused) {
this.paused = Boolean(paused);
}
push(callback) {
const q = this;
const item = {
prev: q.tail,
check() {
if (!q.paused && !this.prev && this.fired) {
callback(this.err, this.data, this.response);
if (this.next) {
this.next.prev = null;
this.next.check();
} else { // q.tail===this
q.tail = null;
}
}
}
};
if (q.tail) {
q.tail.next = item;
}
q.tail = item;
return (err, data, response) => {
item.fired = 1;
item.err = err;
item.data = data;
item.response = response;
item.check();
};
}
resume() {
if (!this.paused) {
return;
}
this.paused = false;
let head = this.tail;
while (head && head.prev) {
head = head.prev;
}
if (head) {
head.check();
}
}
}
class RequestManager {
constructor() {
this.openedRequests = [];
}
add(req) {
this.openedRequests.push(req);
}
remove(req) {
const idx = this.openedRequests.indexOf(req);
if (idx !== -1) {
this.openedRequests.splice(idx, 1);
}
}
close() {
for (const openedRequest of this.openedRequests) {
openedRequest.abort();
}
this.openedRequests = [];
}
size() {
return this.openedRequests.length;
}
}
function pad(number) {
if (number < 10) {
return "0" + number;
}
return number;
}
function toLastModifiedString(date) {
return pad(date.getMonth() + 1) +
"/" + pad(date.getDate()) +
"/" + date.getFullYear() +
" " + pad(date.getHours()) +
":" + pad(date.getMinutes()) +
":" + pad(date.getSeconds());
}
const nonInheritedTags = new Set([
"article", "section", "nav", "aside", "hgroup", "header", "footer", "address", "dt",
"dd", "figure", "figcaption", "main", "em", "strong", "small", "s", "cite", "dfn", "abbr",
"ruby", "rt", "rp", "code", "var", "samp", "kbd", "i", "b", "u", "mark", "bdi", "bdo", "wbr"
]);
const eventInterfaceTable = {
customevent: CustomEvent,
errorevent: ErrorEvent,
event: Event,
events: Event,
focusevent: FocusEvent,
hashchangeevent: HashChangeEvent,
htmlevents: Event,
keyboardevent: KeyboardEvent,
messageevent: MessageEvent,
mouseevent: MouseEvent,
mouseevents: MouseEvent,
popstateevent: PopStateEvent,
progressevent: ProgressEvent,
svgevents: Event,
touchevent: TouchEvent,
uievent: UIEvent,
uievents: UIEvent
};
class DocumentImpl extends NodeImpl {
constructor(args, privateData) {
super(args, privateData);
this._ownerDocument = this;
this.nodeType = NODE_TYPE.DOCUMENT_NODE;
if (!privateData.options) {
privateData.options = {};
}
if (!privateData.options.parsingMode) {
privateData.options.parsingMode = "xml";
}
this._parsingMode = privateData.options.parsingMode;
this._htmlToDom = new HtmlToDom(privateData.core, privateData.options.parser, privateData.options.parsingMode);
this._implementation = DOMImplementation.createImpl([], {
core: this._core,
ownerDocument: this
});
this._defaultView = privateData.options.defaultView || null;
this._global = privateData.options.global;
this._documentElement = null;
this._ids = Object.create(null);
this._attached = true;
this._currentScript = null;
this._cookieJar = privateData.options.cookieJar;
if (this._cookieJar === undefined) {
this._cookieJar = new CookieJar(null, { looseMode: true });
}
this._contentType = privateData.options.contentType;
this._encoding = privateData.options.encoding;
const urlOption = privateData.options.url === undefined ? "about:blank" : privateData.options.url;
const parsed = whatwgURL.parseURL(urlOption);
if (parsed === "failure") {
throw new TypeError(`Could not parse "${urlOption}" as a URL`);
}
this._URL = parsed;
this._origin = whatwgURL.serializeURLToUnicodeOrigin(parsed);
this._location = Location.createImpl([], { relevantDocument: this });
this._history = History.createImpl([], {
window: this._defaultView,
document: this,
actAsIfLocationReloadCalled: () => this._location.reload()
});
if (privateData.options.cookie) {
const cookies = Array.isArray(privateData.options.cookie) ?
privateData.options.cookie : [privateData.options.cookie];
const document = this;
cookies.forEach(cookieStr => {
document._cookieJar.setCookieSync(cookieStr, document.URL, { ignoreError: true });
});
}
this._activeNodeIterators = [];
this._activeNodeIteratorsMax = privateData.options.concurrentNodeIterators === undefined ?
10 :
Number(privateData.options.concurrentNodeIterators);
if (isNaN(this._activeNodeIteratorsMax)) {
throw new TypeError("The 'concurrentNodeIterators' option must be a Number");
}
if (this._activeNodeIteratorsMax < 0) {
throw new RangeError("The 'concurrentNodeIterators' option must be a non negative Number");
}
this._referrer = privateData.options.referrer || "";
this._lastModified = toLastModifiedString(privateData.options.lastModified || new Date());
this._queue = new ResourceQueue(privateData.options.deferClose);
this._customResourceLoader = privateData.options.resourceLoader;
this._pool = privateData.options.pool;
this._agentOptions = privateData.options.agentOptions;
this._strictSSL = privateData.options.strictSSL;
this._proxy = privateData.options.proxy;
this._requestManager = new RequestManager();
this.readyState = "loading";
this._lastFocusedElement = null;
// Add level2 features
this.implementation._addFeature("core", "2.0");
this.implementation._addFeature("html", "2.0");
this.implementation._addFeature("xhtml", "2.0");
this.implementation._addFeature("xml", "2.0");
}
_defaultElementBuilder(document, tagName) {
if (nonInheritedTags.has(tagName.toLowerCase())) {
return HTMLElement.create([], {
core: this._core,
ownerDocument: this,
localName: tagName
});
}
return HTMLUnknownElement.create([], {
core: this._core,
ownerDocument: this,
localName: tagName
});
}
get contentType() {
return this._contentType || (this._parsingMode === "xml" ? "application/xml" : "text/html");
}
get compatMode() {
return this._parsingMode === "xml" || this.doctype ? "CSS1Compat" : "BackCompat";
}
get charset() {
return this._encoding;
}
get characterSet() {
return this._encoding;
}
get inputEncoding() {
return this._encoding;
}
get doctype() {
for (const childNode of domSymbolTree.childrenIterator(this)) {
if (childNode.nodeType === NODE_TYPE.DOCUMENT_TYPE_NODE) {
return childNode;
}
}
return null;
}
get URL() {
return whatwgURL.serializeURL(this._URL);
}
get documentURI() {
return whatwgURL.serializeURL(this._URL);
}
get origin() {
return this._origin;
}
get location() {
return this._defaultView ? this._location : null;
}
get documentElement() {
if (this._documentElement) {
return this._documentElement;
}
for (const childNode of domSymbolTree.childrenIterator(this)) {
if (childNode.nodeType === NODE_TYPE.ELEMENT_NODE) {
this._documentElement = childNode;
return childNode;
}
}
return null;
}
get implementation() {
return this._implementation;
}
set implementation(implementation) {
this._implementation = implementation;
}
get defaultView() {
return this._defaultView;
}
get currentScript() {
return this._currentScript;
}
get activeElement() {
if (this._lastFocusedElement) {
return this._lastFocusedElement;
}
return this.body;
}
hasFocus() {
return Boolean(this._lastFocusedElement);
}
toString() {
return "[object HTMLDocument]";
}
_createElementWithCorrectElementInterface(name, namespace) {
// https://dom.spec.whatwg.org/#concept-element-interface
// TODO: eventually we should re-write the element-builder system to be namespace aware, but for now it is not.
const builder = this._elementBuilders[name.toLowerCase()] || this._defaultElementBuilder.bind(this);
const elem = builder(this, name, namespace);
return idlUtils.implForWrapper(elem);
}
appendChild(/* Node */ arg) {
if (this.documentElement && arg.nodeType === NODE_TYPE.ELEMENT_NODE) {
throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
return super.appendChild(arg);
}
removeChild(/* Node */ arg) {
const ret = super.removeChild(arg);
if (arg === this._documentElement) {
this._documentElement = null;// force a recalculation
}
return ret;
}
_descendantRemoved(parent, child) {
if (child.tagName === "STYLE") {
const index = this.styleSheets.indexOf(child.sheet);
if (index > -1) {
this.styleSheets.splice(index, 1);
}
}
}
write() {
let text = "";
for (let i = 0; i < arguments.length; ++i) {
text += String(arguments[i]);
}
if (this._parsingMode === "xml") {
throw new DOMException(DOMException.INVALID_STATE_ERR, "Cannot use document.write on XML documents");
}
if (this._writeAfterElement) {
// If called from an script element directly (during the first tick),
// the new elements are inserted right after that element.
const tempDiv = this.createElement("div");
setInnerHTML(this, tempDiv, text);
let child = tempDiv.firstChild;
let previous = this._writeAfterElement;
const parent = this._writeAfterElement.parentNode;
while (child) {
const node = child;
child = child.nextSibling;
parent.insertBefore(node, previous.nextSibling);
previous = node;
}
} else if (this.readyState === "loading") {
// During page loading, document.write appends to the current element
// Find the last child that has been added to the document.
let node = this;
while (node.lastChild && node.lastChild.nodeType === NODE_TYPE.ELEMENT_NODE) {
node = node.lastChild;
}
setInnerHTML(this, node, text);
} else if (text) {
setInnerHTML(this, this, text);
}
}
writeln() {
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args.push(arguments[i]);
}
args.push("\n");
this.write.apply(this, args);
}
getElementById(id) {
// return the first element
return this._ids[id] && this._ids[id].length > 0 ? this._ids[id][0] : null;
}
get referrer() {
return this._referrer || "";
}
get lastModified() {
return this._lastModified;
}
get images() {
return this.getElementsByTagName("IMG");
}
get embeds() {
return this.getElementsByTagName("EMBED");
}
get plugins() {
return this.embeds;
}
get links() {
return createHTMLCollection(this, () => domSymbolTree.treeToArray(this, { filter(node) {
return (node._localName === "a" || node._localName === "area") &&
node.hasAttribute("href") &&
node._namespaceURI === "http://www.w3.org/1999/xhtml";
} }));
}
get forms() {
return this.getElementsByTagName("FORM");
}
get scripts() {
return this.getElementsByTagName("SCRIPT");
}
get anchors() {
return createHTMLCollection(this, () => domSymbolTree.treeToArray(this, { filter(node) {
return node._localName === "a" &&
node.hasAttribute("name") &&
node._namespaceURI === "http://www.w3.org/1999/xhtml";
} }));
}
get applets() {
return this.getElementsByTagName("APPLET");
}
open() {
let child = domSymbolTree.firstChild(this);
while (child) {
this.removeChild(child);
child = domSymbolTree.firstChild(this);
}
this._documentElement = null;
this._modified();
return this;
}
close() {
this._queue.resume();
// Set the readyState to 'complete' once all resources are loaded.
// As a side-effect the document's load-event will be dispatched.
resourceLoader.enqueue(this, null, function () {
this.readyState = "complete";
const ev = this.createEvent("HTMLEvents");
ev.initEvent("DOMContentLoaded", false, false);
this.dispatchEvent(ev);
})(null, true);
}
getElementsByName(elementName) {
// TODO: should be NodeList, should be memoized
return createHTMLCollection(this, () => domSymbolTree.treeToArray(this, { filter(node) {
return node.getAttribute && node.getAttribute("name") === elementName;
} }));
}
get title() {
// TODO SVG
const titleElement = firstDescendantWithHTMLLocalName(this, "title");
let value = titleElement !== null ? titleElement.textContent : "";
value = stripAndCollapseASCIIWhitespace(value);
return value;
}
set title(val) {
// TODO SVG
const titleElement = firstDescendantWithHTMLLocalName(this, "title");
const headElement = this.head;
if (titleElement === null && headElement === null) {
return;
}
let element;
if (titleElement !== null) {
element = titleElement;
} else {
element = this.createElement("title");
headElement.appendChild(element);
}
element.textContent = val;
}
get head() {
return this.documentElement ? firstChildWithHTMLLocalName(this.documentElement, "head") : null;
}
get body() {
const documentElement = this.documentElement;
if (!documentElement || documentElement._localName !== "html" ||
documentElement._namespaceURI !== "http://www.w3.org/1999/xhtml") {
return null;
}
return firstChildWithHTMLLocalNames(this.documentElement, new Set(["body", "frameset"]));
}
set body(value) {
if (!HTMLElement.isImpl(value)) {
throw new TypeError("Argument must be a HTMLElement");
}
if (value._namespaceURI !== "http://www.w3.org/1999/xhtml" ||
(value._localName !== "body" && value._localName !== "frameset")) {
throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Cannot set the body to a non-body/frameset element");
}
const bodyElement = this.body;
if (value === bodyElement) {
return;
}
if (bodyElement !== null) {
bodyElement.parentNode.replaceChild(value, bodyElement);
return;
}
const documentElement = this.documentElement;
if (documentElement === null) {
throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
"Cannot set the body when there is no document element");
}
documentElement.appendChild(value);
}
_runRemovingSteps(oldNode, oldParent, oldPreviousSibling) {
const listeners = DocumentImpl._removingSteps;
for (let i = 0; i < listeners.length; ++i) {
listeners[i](this, oldNode, oldParent, oldPreviousSibling);
}
}
createEvent(type) {
const typeLower = type.toLowerCase();
const eventWrapper = eventInterfaceTable[typeLower] || null;
if (!eventWrapper) {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"The provided event type (\"" + type + "\") is invalid");
}
const impl = eventWrapper.createImpl([""]);
impl._initializedFlag = false;
return impl;
}
createProcessingInstruction(target, data) {
validateName(target);
if (data.indexOf("?>") !== -1) {
throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
"Processing instruction data cannot contain the string \"?>\"");
}
return ProcessingInstruction.createImpl([], {
core: this._core,
ownerDocument: this,
target,
data
});
}
// https://dom.spec.whatwg.org/#dom-document-createcdatasection
createCDATASection(data) {
if (this._parsingMode === "html") {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Cannot create CDATA sections in HTML documents");
}
if (data.indexOf("]]>") !== -1) {
throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
"CDATA section data cannot contain the string \"]]>\"");
}
return CDATASection.createImpl([], {
core: this._core,
ownerDocument: this,
data
});
}
createTextNode(data) {
return Text.createImpl([], {
core: this._core,
ownerDocument: this,
data
});
}
createComment(data) {
return Comment.createImpl([], {
core: this._core,
ownerDocument: this,
data
});
}
createElement(localName) {
validateName(localName);
if (this._parsingMode === "html") {
localName = localName.toLowerCase();
}
const element = this._createElementWithCorrectElementInterface(localName, "http://www.w3.org/1999/xhtml");
element._namespaceURI = "http://www.w3.org/1999/xhtml";
element._localName = localName;
return element;
}
createElementNS(namespace, qualifiedName) {
namespace = namespace !== null ? String(namespace) : namespace;
const extracted = validateAndExtract(namespace, qualifiedName);
const element = this._createElementWithCorrectElementInterface(extracted.localName, extracted.namespace);
element._namespaceURI = extracted.namespace;
element._prefix = extracted.prefix;
element._localName = extracted.localName;
return element;
}
createDocumentFragment() {
return DocumentFragment.createImpl([], { ownerDocument: this });
}
createAttribute(localName) {
validateName(localName);
if (this._parsingMode === "html") {
localName = localName.toLowerCase();
}
return generatedAttr.createImpl([], { localName });
}
createAttributeNS(namespace, name) {
if (namespace === undefined) {
namespace = null;
}
namespace = namespace !== null ? String(namespace) : namespace;
const extracted = validateAndExtract(namespace, name);
return generatedAttr.createImpl([], {
namespace: extracted.namespace,
namespacePrefix: extracted.prefix,
localName: extracted.localName
});
}
// TODO: Add callback interface support to `webidl2js`
createTreeWalker(root, whatToShow, filter) {
if (!isNodeImpl(root)) {
throw new TypeError("First argument to createTreeWalker must be a Node");
}
return TreeWalker.createImpl([], {
root,
whatToShow,
filter
});
}
importNode(node, deep) {
if (!isNodeImpl(node)) {
throw new TypeError("First argument to importNode must be a Node");
}
deep = Boolean(deep);
if (node.nodeType === NODE_TYPE.DOCUMENT_NODE) {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Cannot import a document node");
}
return clone(this._core, node, this, deep);
}
adoptNode(node) {
if (!isNodeImpl(node)) {
throw new TypeError("First argument to adoptNode must be a Node");
}
if (node.nodeType === NODE_TYPE.DOCUMENT_NODE) {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Cannot adopt a document node");
}
// TODO: Determine correct way to detect a shadow root
// See also https://github.com/w3c/webcomponents/issues/182
if (node.parentNode) {
node.parentNode.removeChild(node);
}
node._ownerDocument = this;
for (const descendant of domSymbolTree.treeIterator(node)) {
descendant._ownerDocument = this;
}
return node;
}
get cookie() {
return this._cookieJar.getCookieStringSync(this.URL, { http: false });
}
set cookie(cookieStr) {
cookieStr = String(cookieStr);
this._cookieJar.setCookieSync(cookieStr, this.URL, {
http: false,
ignoreError: true
});
}
get styleSheets() {
if (!this._styleSheets) {
this._styleSheets = new this._core.StyleSheetList();
}
// TODO: each style and link element should register its sheet on creation
// and remove it on removal.
return this._styleSheets;
}
get hidden() {
return true;
}
get visibilityState() {
return "prerender";
}
}
idlUtils.mixin(DocumentImpl.prototype, ParentNodeImpl.prototype);
DocumentImpl._removingSteps = [];
DocumentImpl.prototype._elementBuilders = Object.create(null);
DocumentImpl.prototype.getElementsByTagName = memoizeQuery(function (qualifiedName) {
return listOfElementsWithQualifiedName(qualifiedName, this);
});
DocumentImpl.prototype.getElementsByTagNameNS = memoizeQuery(function (namespace, localName) {
return listOfElementsWithNamespaceAndLocalName(namespace, localName, this);
});
DocumentImpl.prototype.getElementsByClassName = memoizeQuery(function getElementsByClassName(classNames) {
return listOfElementsWithClassNames(classNames, this);
});
module.exports = {
implementation: DocumentImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1 1 1 1 1 1 | "use strict";
const idlUtils = require("../generated/utils");
const NodeImpl = require("./Node-impl").implementation;
const ParentNodeImpl = require("./ParentNode-impl").implementation;
const NODE_TYPE = require("../node-type");
class DocumentFragmentImpl extends NodeImpl {
constructor(args, privateData) {
super(args, privateData);
this.nodeType = NODE_TYPE.DOCUMENT_FRAGMENT_NODE;
}
}
idlUtils.mixin(DocumentFragmentImpl.prototype, ParentNodeImpl.prototype);
module.exports = {
implementation: DocumentFragmentImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1 1 1 1 1 1 | "use strict";
const idlUtils = require("../generated/utils");
const NodeImpl = require("./Node-impl").implementation;
const ChildNodeImpl = require("./ChildNode-impl").implementation;
const NODE_TYPE = require("../node-type");
class DocumentTypeImpl extends NodeImpl {
constructor(args, privateData) {
super(args, privateData);
this.nodeType = NODE_TYPE.DOCUMENT_TYPE_NODE;
this.name = privateData.name;
this.publicId = privateData.publicId;
this.systemId = privateData.systemId;
}
}
idlUtils.mixin(DocumentTypeImpl.prototype, ChildNodeImpl.prototype);
module.exports = {
implementation: DocumentTypeImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const vm = require("vm");
const nwmatcher = require("nwmatcher/src/nwmatcher-noqsa");
const idlUtils = require("../generated/utils");
const NodeImpl = require("./Node-impl").implementation;
const ParentNodeImpl = require("./ParentNode-impl").implementation;
const ChildNodeImpl = require("./ChildNode-impl").implementation;
const attributes = require("../attributes");
const namedPropertiesWindow = require("../named-properties-window");
const NODE_TYPE = require("../node-type");
const domToHtml = require("../../browser/domtohtml").domToHtml;
const memoizeQuery = require("../../utils").memoizeQuery;
const clone = require("../node").clone;
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const resetDOMTokenList = require("../dom-token-list").reset;
const DOMException = require("../../web-idl/DOMException");
const createDOMTokenList = require("../dom-token-list").create;
const attrGenerated = require("../generated/Attr");
const validateNames = require("../helpers/validate-names");
const listOfElementsWithQualifiedName = require("../node").listOfElementsWithQualifiedName;
const listOfElementsWithNamespaceAndLocalName = require("../node").listOfElementsWithNamespaceAndLocalName;
const listOfElementsWithClassNames = require("../node").listOfElementsWithClassNames;
const proxiedWindowEventHandlers = require("../helpers/proxied-window-event-handlers");
const NonDocumentTypeChildNode = require("./NonDocumentTypeChildNode-impl").implementation;
// nwmatcher gets `document.documentElement` at creation-time, so we have to initialize lazily, since in the initial
// stages of Document initialization, there is no documentElement present yet.
function addNwmatcher(parentNode) {
const document = parentNode._ownerDocument;
if (!document._nwmatcher) {
document._nwmatcher = nwmatcher({ document });
document._nwmatcher.configure({ UNIQUE_ID: false });
}
return document._nwmatcher;
}
function clearChildNodes(node) {
for (let child = domSymbolTree.firstChild(node); child; child = domSymbolTree.firstChild(node)) {
node.removeChild(child);
}
}
function setInnerHTML(document, node, html) {
// Clear the children first:
if (node._templateContents) {
clearChildNodes(node._templateContents);
} else {
clearChildNodes(node);
}
if (html !== "") {
if (node.nodeName === "#document") {
document._htmlToDom.appendHtmlToDocument(html, node);
} else {
document._htmlToDom.appendHtmlToElement(html, node);
}
}
}
function attachId(id, elm, doc) {
if (id && elm && doc) {
if (!doc._ids[id]) {
doc._ids[id] = [];
}
doc._ids[id].push(elm);
}
}
function detachId(id, elm, doc) {
if (id && elm && doc) {
if (doc._ids && doc._ids[id]) {
const elms = doc._ids[id];
for (let i = 0; i < elms.length; i++) {
if (elms[i] === elm) {
elms.splice(i, 1);
--i;
}
}
if (elms.length === 0) {
delete doc._ids[id];
}
}
}
}
class ElementImpl extends NodeImpl {
constructor(args, privateData) {
super(args, privateData);
this.nodeType = NODE_TYPE.ELEMENT_NODE;
this.scrollTop = 0;
this.scrollLeft = 0;
this._namespaceURI = null;
this._prefix = null;
this._localName = privateData.localName;
this._attributes = attributes.createNamedNodeMap(this);
}
_attach() {
namedPropertiesWindow.nodeAttachedToDocument(this);
const id = this.getAttribute("id");
if (id) {
attachId(id, this, this._ownerDocument);
}
super._attach();
}
_detach() {
super._detach();
namedPropertiesWindow.nodeDetachedFromDocument(this);
const id = this.getAttribute("id");
if (id) {
detachId(id, this, this._ownerDocument);
}
}
_attrModified(name, value, oldValue) {
this._modified();
namedPropertiesWindow.elementAttributeModified(this, name, value, oldValue);
if (name === "id" && this._attached) {
const doc = this._ownerDocument;
detachId(oldValue, this, doc);
attachId(value, this, doc);
}
const w = this._ownerDocument._global;
// TODO event handlers:
// The correct way to do this is lazy, and a bit more complicated; see
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-content-attributes
// It would only be possible if we had proper getters/setters for every event handler, which we don't right now.
if (name.length > 2 && name[0] === "o" && name[1] === "n") {
// If this document does not have a window, set IDL attribute to null
// step 2: https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler
if (value && w) {
const self = proxiedWindowEventHandlers.has(name) && this._localName === "body" ? w : this;
const vmOptions = { filename: this._ownerDocument.URL, displayErrors: false };
// The handler code probably refers to functions declared globally on the window, so we need to run it in
// that context. In fact, it's worse; see
// https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/bindings/core/v8/V8LazyEventListener.cpp
// plus the spec, which show how multiple nested scopes are technically required. We won't implement that
// until someone asks for it, though.
// https://html.spec.whatwg.org/multipage/webappapis.html#the-event-handler-processing-algorithm
if (name === "onerror" && self === w) {
// https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler
// step 10
self[name] = function (event, source, lineno, colno, error) {
w.__tempEventHandlerThis = this;
w.__tempEventHandlerEvent = event;
w.__tempEventHandlerSource = source;
w.__tempEventHandlerLineno = lineno;
w.__tempEventHandlerColno = colno;
w.__tempEventHandlerError = error;
try {
return vm.runInContext(`
(function (event, source, lineno, colno, error) {
${value}
}).call(__tempEventHandlerThis, __tempEventHandlerEvent, __tempEventHandlerSource,
__tempEventHandlerLineno, __tempEventHandlerColno, __tempEventHandlerError)`, w, vmOptions);
} finally {
delete w.__tempEventHandlerThis;
delete w.__tempEventHandlerEvent;
delete w.__tempEventHandlerSource;
delete w.__tempEventHandlerLineno;
delete w.__tempEventHandlerColno;
delete w.__tempEventHandlerError;
}
};
} else {
self[name] = function (event) {
w.__tempEventHandlerThis = this;
w.__tempEventHandlerEvent = event;
try {
return vm.runInContext(`
(function (event) {
${value}
}).call(__tempEventHandlerThis, __tempEventHandlerEvent)`, w, vmOptions);
} finally {
delete w.__tempEventHandlerThis;
delete w.__tempEventHandlerEvent;
}
};
}
} else {
this[name] = null;
}
}
// update classList
if (name === "class") {
resetDOMTokenList(this.classList, value);
}
}
get namespaceURI() {
return this._namespaceURI;
}
get prefix() {
return this._prefix;
}
get localName() {
return this._localName;
}
get _qualifiedName() {
return this._prefix !== null ? this._prefix + ":" + this._localName : this._localName;
}
get tagName() {
let qualifiedName = this._qualifiedName;
if (this.namespaceURI === "http://www.w3.org/1999/xhtml" && this._ownerDocument._parsingMode === "html") {
qualifiedName = qualifiedName.toUpperCase();
}
return qualifiedName;
}
get attributes() {
return this._attributes;
}
get outerHTML() {
return domToHtml([this]);
}
set outerHTML(html) {
if (html === null) {
html = "";
}
const parent = domSymbolTree.parent(this);
const document = this._ownerDocument;
if (!parent) {
return;
}
let contextElement;
if (parent.nodeType === NODE_TYPE.DOCUMENT_NODE) {
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
"Modifications are not allowed for this document");
} else if (parent.nodeType === NODE_TYPE.DOCUMENT_FRAGMENT_NODE) {
contextElement = document.createElementNS("http://www.w3.org/1999/xhtml", "body");
} else if (parent.nodeType === NODE_TYPE.ELEMENT_NODE) {
contextElement = clone(this._core, parent, undefined, false);
} else {
throw new TypeError("This should never happen");
}
document._htmlToDom.appendHtmlToElement(html, contextElement);
while (contextElement.firstChild) {
parent.insertBefore(contextElement.firstChild, this);
}
parent.removeChild(this);
}
get innerHTML() {
const tagName = this.tagName;
if (tagName === "SCRIPT" || tagName === "STYLE") {
const type = this.getAttribute("type");
if (!type || /^text\//i.test(type) || /\/javascript$/i.test(type)) {
return domToHtml(domSymbolTree.childrenIterator(this));
}
}
// In case of <template> we should pass its "template contents" fragment as a serialization root if we have one
if (this._templateContents) {
return domToHtml(domSymbolTree.childrenIterator(this._templateContents));
}
return domToHtml(domSymbolTree.childrenIterator(this));
}
set innerHTML(html) {
if (html === null) {
html = "";
}
setInnerHTML(this.ownerDocument, this, html);
}
get classList() {
if (this._classList === undefined) {
this._classList = createDOMTokenList(this, "class");
}
return this._classList;
}
hasAttributes() {
return attributes.hasAttributes(this);
}
getAttributeNames() {
return attributes.attributeNames(this);
}
getAttribute(name) {
return attributes.getAttributeValue(this, name);
}
getAttributeNS(namespace, localName) {
return attributes.getAttributeValueByNameNS(this, namespace, localName);
}
setAttribute(name, value) {
validateNames.name(name);
if (this._namespaceURI === "http://www.w3.org/1999/xhtml" && this._ownerDocument._parsingMode === "html") {
name = name.toLowerCase();
}
const attribute = attributes.getAttributeByName(this, name);
if (attribute === null) {
const newAttr = attrGenerated.createImpl([], { localName: name, value });
attributes.appendAttribute(this, newAttr);
return;
}
attributes.changeAttribute(this, attribute, value);
}
setAttributeNS(namespace, name, value) {
const extracted = validateNames.validateAndExtract(namespace, name);
attributes.setAttributeValue(this, extracted.localName, value, extracted.prefix, extracted.namespace);
}
removeAttribute(name) {
attributes.removeAttributeByName(this, name);
}
removeAttributeNS(namespace, localName) {
attributes.removeAttributeByNameNS(this, namespace, localName);
}
hasAttribute(name) {
if (this._namespaceURI === "http://www.w3.org/1999/xhtml" && this._ownerDocument._parsingMode === "html") {
name = name.toLowerCase();
}
return attributes.hasAttributeByName(this, name);
}
hasAttributeNS(namespace, localName) {
if (namespace === "") {
namespace = null;
}
return attributes.hasAttributeByNameNS(this, namespace, localName);
}
getAttributeNode(name) {
return attributes.getAttributeByName(this, name);
}
getAttributeNodeNS(namespace, localName) {
return attributes.getAttributeByNameNS(this, namespace, localName);
}
setAttributeNode(attr) {
if (!attrGenerated.isImpl(attr)) {
throw new TypeError("First argument to Element.prototype.setAttributeNode must be an Attr");
}
return attributes.setAttribute(this, attr);
}
setAttributeNodeNS(attr) {
if (!attrGenerated.isImpl(attr)) {
throw new TypeError("First argument to Element.prototype.setAttributeNodeNS must be an Attr");
}
return attributes.setAttribute(this, attr);
}
removeAttributeNode(attr) {
if (!attrGenerated.isImpl(attr)) {
throw new TypeError("First argument to Element.prototype.removeAttributeNode must be an Attr");
}
if (!attributes.hasAttribute(this, attr)) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "Tried to remove an attribute that was not present");
}
attributes.removeAttribute(this, attr);
return attr;
}
getBoundingClientRect() {
return {
bottom: 0,
height: 0,
left: 0,
right: 0,
top: 0,
width: 0
};
}
getClientRects() {
return [];
}
get scrollWidth() {
return 0;
}
get scrollHeight() {
return 0;
}
get clientTop() {
return 0;
}
get clientLeft() {
return 0;
}
get clientWidth() {
return 0;
}
get clientHeight() {
return 0;
}
// https://w3c.github.io/DOM-Parsing/#dom-element-insertadjacenthtml
insertAdjacentHTML(position, text) {
position = position.toLowerCase();
let context;
switch (position) {
case "beforebegin":
case "afterend": {
context = this.parentNode;
if (context === null || context.nodeType === NODE_TYPE.DOCUMENT_NODE) {
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Cannot insert HTML adjacent to " +
"parent-less nodes or children of document nodes.");
}
break;
}
case "afterbegin":
case "beforeend": {
context = this;
break;
}
default: {
throw new DOMException(DOMException.SYNTAX_ERR, "Must provide one of \"beforebegin\", \"afterend\", " +
"\"afterbegin\", or \"beforeend\".");
}
}
// TODO: use context for parsing instead of a <template>.
const fragment = this.ownerDocument.createElement("template");
fragment.innerHTML = text;
switch (position) {
case "beforebegin": {
this.parentNode.insertBefore(fragment.content, this);
break;
}
case "afterbegin": {
this.insertBefore(fragment.content, this.firstChild);
break;
}
case "beforeend": {
this.appendChild(fragment.content);
break;
}
case "afterend": {
this.parentNode.insertBefore(fragment.content, this.nextSibling);
break;
}
}
}
}
idlUtils.mixin(ElementImpl.prototype, NonDocumentTypeChildNode.prototype);
idlUtils.mixin(ElementImpl.prototype, ParentNodeImpl.prototype);
idlUtils.mixin(ElementImpl.prototype, ChildNodeImpl.prototype);
ElementImpl.prototype.getElementsByTagName = memoizeQuery(function (qualifiedName) {
return listOfElementsWithQualifiedName(qualifiedName, this);
});
ElementImpl.prototype.getElementsByTagNameNS = memoizeQuery(function (namespace, localName) {
return listOfElementsWithNamespaceAndLocalName(namespace, localName, this);
});
ElementImpl.prototype.getElementsByClassName = memoizeQuery(function (classNames) {
return listOfElementsWithClassNames(classNames, this);
});
ElementImpl.prototype.matches = memoizeQuery(function (selectors) {
const matcher = addNwmatcher(this);
try {
return matcher.match(idlUtils.wrapperForImpl(this), selectors);
} catch (e) {
throw new DOMException(DOMException.SYNTAX_ERR, e.message);
}
});
ElementImpl.prototype.webkitMatchesSelector = ElementImpl.prototype.matches;
module.exports = {
implementation: ElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 | 1 | "use strict";
class ElementCSSInlineStyle { }
module.exports = {
implementation: ElementCSSInlineStyle
};
|
| 1 2 3 4 5 6 7 8 9 | 1 | "use strict";
class ElementContentEditableImpl { }
module.exports = {
implementation: ElementContentEditableImpl
};
|
| 1 2 3 4 5 6 7 8 9 | 1 | "use strict";
class GlobalEventHandlersImpl { }
module.exports = {
implementation: GlobalEventHandlersImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1 1 1 1 1 | "use strict";
const idlUtils = require("../generated/utils");
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const HTMLHyperlinkElementUtilsImpl = require("./HTMLHyperlinkElementUtils-impl").implementation;
class HTMLAnchorElementImpl extends HTMLElementImpl {
constructor(args, privateData) {
super(args, privateData);
this._htmlHyperlinkElementUtilsSetup();
}
get text() {
return this.textContent;
}
set text(v) {
this.textContent = v;
}
}
idlUtils.mixin(HTMLAnchorElementImpl.prototype, HTMLHyperlinkElementUtilsImpl.prototype);
module.exports = {
implementation: HTMLAnchorElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
class HTMLAppletElementImpl extends HTMLElementImpl {
get object() {
return reflectURLAttribute(this, "object");
}
set object(V) {
this.setAttribute("object", V);
}
get codeBase() {
return reflectURLAttribute(this, "codebase");
}
set codeBase(V) {
this.setAttribute("codebase", V);
}
}
module.exports = {
implementation: HTMLAppletElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1 1 1 1 1 | "use strict";
const idlUtils = require("../generated/utils");
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const HTMLHyperlinkElementUtilsImpl = require("./HTMLHyperlinkElementUtils-impl").implementation;
class HTMLAreaElementImpl extends HTMLElementImpl {
constructor(args, privateData) {
super(args, privateData);
this._htmlHyperlinkElementUtilsSetup();
}
}
idlUtils.mixin(HTMLAreaElementImpl.prototype, HTMLHyperlinkElementUtilsImpl.prototype);
module.exports = {
implementation: HTMLAreaElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLMediaElementImpl = require("./HTMLMediaElement-impl").implementation;
class HTMLAudioElementImpl extends HTMLMediaElementImpl { }
module.exports = {
implementation: HTMLAudioElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLBRElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLBRElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const whatwgURL = require("whatwg-url");
const fallbackBaseURL = require("../helpers/document-base-url").fallbackBaseURL;
class HTMLBaseElement extends HTMLElementImpl {
get href() {
const document = this._ownerDocument;
const url = this.hasAttribute("href") ? this.getAttribute("href") : "";
const parsed = whatwgURL.parseURL(url, { baseURL: fallbackBaseURL(document) });
if (parsed === "failure") {
return url;
}
return whatwgURL.serializeURL(parsed);
}
set href(value) {
this.setAttribute("href", value);
}
}
module.exports = {
implementation: HTMLBaseElement
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1 1 1 19 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const proxiedWindowEventHandlers = require("../helpers/proxied-window-event-handlers");
class HTMLBodyElementImpl extends HTMLElementImpl {}
for (const name of proxiedWindowEventHandlers) {
Object.defineProperty(HTMLBodyElementImpl.prototype, name, {
configurable: true,
enumerable: true,
get() {
const window = this._ownerDocument._defaultView;
return window ? window[name] : null;
},
set(handler) {
const window = this._ownerDocument._defaultView;
if (window) {
window[name] = handler;
}
}
});
}
module.exports = {
implementation: HTMLBodyElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const closest = require("../helpers/traversal").closest;
const isDisabled = require("../helpers/form-controls").isDisabled;
class HTMLButtonElementImpl extends HTMLElementImpl {
_activationBehavior() {
const form = this.form;
if (form) {
if (this.type === "submit" && !isDisabled(this)) {
form._dispatchSubmitEvent();
}
}
}
_getValue() {
const valueAttr = this.getAttribute("value");
return valueAttr === null ? "" : valueAttr;
}
get form() {
return closest(this, "form");
}
get type() {
const typeAttr = (this.getAttribute("type") || "").toLowerCase();
switch (typeAttr) {
case "submit":
case "reset":
case "button":
case "menu":
return typeAttr;
default:
return "submit";
}
}
set type(v) {
v = String(v).toLowerCase();
switch (v) {
case "submit":
case "reset":
case "button":
case "menu":
this.setAttribute("type", v);
break;
default:
this.setAttribute("type", "submit");
break;
}
}
}
module.exports = {
implementation: HTMLButtonElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const notImplemented = require("../../browser/not-implemented");
const idlUtils = require("../generated/utils");
const Canvas = require("../../utils").Canvas;
class HTMLCanvasElementImpl extends HTMLElementImpl {
_attrModified(name, value) {
if (this._canvas && (name === "width" || name === "height")) {
this._canvas[name] = parseInt(value);
}
return super._attrModified.apply(this, arguments);
}
_getCanvas() {
if (Canvas && !this._canvas) {
this._canvas = new Canvas(this.width, this.height);
}
return this._canvas;
}
getContext(contextId) {
const canvas = this._getCanvas();
if (canvas) {
if (!this._context) {
this._context = canvas.getContext(contextId) || null;
if (this._context) {
// Override the native canvas reference with our wrapper. This is the
// reason why we need to locally cache _context, since each call to
// canvas.getContext(contextId) would replace this reference again.
// Perhaps in the longer term, a better solution would be to create a
// full wrapper for the Context object as well.
this._context.canvas = idlUtils.wrapperForImpl(this);
wrapNodeCanvasMethod(this._context, "createPattern");
wrapNodeCanvasMethod(this._context, "drawImage");
}
}
return this._context;
}
notImplemented("HTMLCanvasElement.prototype.getContext (without installing the canvas npm package)",
this._ownerDocument._defaultView);
return null;
}
probablySupportsContext(contextId) {
const canvas = this._getCanvas();
return canvas ? contextId === "2d" : false;
}
setContext() {
notImplemented("HTMLCanvasElement.prototype.setContext");
}
toDataURL() {
const canvas = this._getCanvas();
if (canvas) {
return canvas.toDataURL.apply(this._canvas, arguments);
}
notImplemented("HTMLCanvasElement.prototype.toDataURL (without installing the canvas npm package)",
this._ownerDocument._defaultView);
return null;
}
toBlob(callback, type, qualityArgument) {
const window = this._ownerDocument._defaultView;
const canvas = this._getCanvas();
if (canvas) {
let stream;
switch (type) {
case "image/jpg":
case "image/jpeg":
stream = canvas.createJPEGStream({
quality: Math.min(0, Math.max(1, qualityArgument)) * 100
});
break;
default:
// TODO: Patch node-canvas to receive qualityArgument for PNG stream
type = "image/png";
stream = canvas.createPNGStream();
}
const buffers = [];
stream.on("data", chunk => {
buffers.push(chunk);
});
stream.on("end", () => {
callback(new window.Blob(buffers, { type }));
});
} else {
notImplemented("HTMLCanvasElement.prototype.toBlob (without installing the canvas npm package)",
window);
}
}
get width() {
const parsed = parseInt(this.getAttribute("width"));
return isNaN(parsed) || parsed < 0 || parsed > 2147483647 ? 300 : parsed;
}
set width(v) {
v = v > 2147483647 ? 300 : v;
this.setAttribute("width", String(v));
}
get height() {
const parsed = parseInt(this.getAttribute("height"));
return isNaN(parsed) || parsed < 0 || parsed > 2147483647 ? 150 : parsed;
}
set height(v) {
v = v > 2147483647 ? 150 : v;
this.setAttribute("height", String(v));
}
}
// We need to wrap the methods that receive an image or canvas object
// (luckily, always as the first argument), so that these objects can be
// unwrapped an the expected types passed.
function wrapNodeCanvasMethod(ctx, name) {
const prev = ctx[name];
ctx[name] = function (image) {
const impl = idlUtils.implForWrapper(image);
if (impl) {
arguments[0] = impl._image || impl._canvas;
}
return prev.apply(ctx, arguments);
};
}
module.exports = {
implementation: HTMLCanvasElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLDListElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLDListElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLDataElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLDataElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLDataListElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLDataListElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLDialogElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLDialogElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLDirectoryElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLDirectoryElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLDivElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLDivElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | 1 1 1 1 1 1 1 | "use strict";
const ElementImpl = require("./Element-impl").implementation;
const MouseEvent = require("../generated/MouseEvent");
const focusing = require("../helpers/focusing.js");
const conversions = require("webidl-conversions");
const isDisabled = require("../helpers/form-controls").isDisabled;
class HTMLElementImpl extends ElementImpl {
constructor(args, privateData) {
super(args, privateData);
this._tabIndex = 0;
this._settingCssText = false;
this._clickInProgress = false;
this._style = new this._core.CSSStyleDeclaration(newCssText => {
if (!this._settingCssText) {
this._settingCssText = true;
this.setAttribute("style", newCssText);
this._settingCssText = false;
}
});
}
// Add default event behavior (click link to navigate, click button to submit
// form, etc). We start by wrapping dispatchEvent so we can forward events to
// the element's default functions (only events that did not incur
// preventDefault).
dispatchEvent(event) {
if (event.type === "click") {
callEventBehaviorHook(event, "_preClickActivationSteps", this);
}
const outcome = super.dispatchEvent(event);
if (event.type === "click") {
if (event.defaultPrevented) {
callEventBehaviorHook(event, "_canceledActivationSteps");
} else {
callEventBehaviorHook(event, "_activationBehavior");
}
}
return outcome;
}
focus() {
if (!focusing.isFocusableAreaElement(this)) {
return;
}
const previous = this._ownerDocument._lastFocusedElement;
focusing.fireFocusEventWithTargetAdjustment("blur", previous, this);
this._ownerDocument._lastFocusedElement = this;
focusing.fireFocusEventWithTargetAdjustment("focus", this, previous);
if (this._ownerDocument._defaultView._frameElement) {
this._ownerDocument._defaultView._frameElement.focus();
}
}
blur() {
if (this._ownerDocument._lastFocusedElement !== this || !focusing.isFocusableAreaElement(this)) {
return;
}
focusing.fireFocusEventWithTargetAdjustment("blur", this, this._ownerDocument);
this._ownerDocument._lastFocusedElement = null;
focusing.fireFocusEventWithTargetAdjustment("focus", this._ownerDocument, this);
}
click() {
// https://html.spec.whatwg.org/multipage/interaction.html#dom-click
// https://html.spec.whatwg.org/multipage/interaction.html#run-synthetic-click-activation-steps
// Not completely spec compliant due to e.g. incomplete implementations of disabled for form controls, or no
// implementation at all of isTrusted.
if (this._clickInProgress) {
return;
}
this._clickInProgress = true;
if (isDisabled(this)) {
return;
}
const event = MouseEvent.createImpl(["click", { bubbles: true, cancelable: true }], {});
// Run synthetic click activation steps. According to the spec,
// this should not be calling dispatchEvent, but it matches browser behavior.
// See: https://www.w3.org/Bugs/Public/show_bug.cgi?id=12230
// See also: https://github.com/whatwg/html/issues/805
this.dispatchEvent(event);
this._clickInProgress = false;
}
get style() {
return this._style;
}
set style(value) {
this._style.cssText = value;
}
_attrModified(name, value, oldValue) {
if (name === "style" && value !== oldValue && !this._settingCssText) {
this._settingCssText = true;
this._style.cssText = value;
this._settingCssText = false;
}
super._attrModified.apply(this, arguments);
}
// TODO this should be [Reflect]able if we added default value support to webidl2js's [Reflect]
get tabIndex() {
if (!this.hasAttribute("tabindex")) {
return focusing.isFocusableAreaElement(this) ? 0 : -1;
}
return conversions.long(this.getAttribute("tabindex"));
}
set tabIndex(value) {
this.setAttribute("tabIndex", String(value));
}
get offsetParent() {
return null;
}
get offsetTop() {
return 0;
}
get offsetLeft() {
return 0;
}
get offsetWidth() {
return 0;
}
get offsetHeight() {
return 0;
}
}
function callEventBehaviorHook(event, name, targetOverride) {
if (event) {
const target = targetOverride || event.target;
if (target && typeof target[name] === "function") {
target[name]();
}
}
}
module.exports = {
implementation: HTMLElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
class HTMLEmbedElementImpl extends HTMLElementImpl {
get src() {
return reflectURLAttribute(this, "src");
}
set src(value) {
this.setAttribute("src", value);
}
}
module.exports = {
implementation: HTMLEmbedElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const closest = require("../helpers/traversal").closest;
class HTMLFieldSetElementImpl extends HTMLElementImpl {
get form() {
return closest(this, "form");
}
}
module.exports = {
implementation: HTMLFieldSetElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLFontElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLFontElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const idlUtils = require("../generated/utils");
const descendantsByHTMLLocalNames = require("../helpers/traversal").descendantsByHTMLLocalNames;
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const createHTMLCollection = require("../../living/html-collection").create;
const notImplemented = require("../../browser/not-implemented");
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
// http://www.whatwg.org/specs/web-apps/current-work/#category-listed
const listedElements = new Set(["button", "fieldset", "input", "keygen", "object", "select", "textarea"]);
const encTypes = new Set([
"application/x-www-form-urlencoded",
"multipart/form-data",
"text/plain"
]);
const methods = new Set([
"get",
"post",
"dialog"
]);
class HTMLFormElementImpl extends HTMLElementImpl {
_descendantAdded(parent, child) {
const form = this;
for (const el of domSymbolTree.treeIterator(child)) {
if (typeof el._changedFormOwner === "function") {
el._changedFormOwner(form);
}
}
super._descendantAdded.apply(this, arguments);
}
_descendantRemoved(parent, child) {
for (const el of domSymbolTree.treeIterator(child)) {
if (typeof el._changedFormOwner === "function") {
el._changedFormOwner(null);
}
}
super._descendantRemoved.apply(this, arguments);
}
get elements() {
return createHTMLCollection(this, () => descendantsByHTMLLocalNames(this, listedElements));
}
get length() {
return this.elements.length;
}
_dispatchSubmitEvent() {
const ev = this._ownerDocument.createEvent("HTMLEvents");
ev.initEvent("submit", true, true);
if (this.dispatchEvent(ev)) {
this.submit();
}
}
submit() {
notImplemented("HTMLFormElement.prototype.submit", this._ownerDocument._defaultView);
}
reset() {
Array.prototype.forEach.call(this.elements, el => {
el = idlUtils.implForWrapper(el);
if (typeof el._formReset === "function") {
el._formReset();
}
});
}
get method() {
let method = this.getAttribute("method");
if (method) {
method = method.toLowerCase();
}
if (methods.has(method)) {
return method;
}
return "get";
}
set method(V) {
this.setAttribute("method", V);
}
get enctype() {
let type = this.getAttribute("enctype");
if (type) {
type = type.toLowerCase();
}
if (encTypes.has(type)) {
return type;
}
return "application/x-www-form-urlencoded";
}
set enctype(V) {
this.setAttribute("enctype", V);
}
get action() {
const attributeValue = this.getAttribute("action");
if (attributeValue === null || attributeValue === "") {
return this._ownerDocument.URL;
}
return reflectURLAttribute(this, "action");
}
set action(V) {
this.setAttribute("action", V);
}
}
module.exports = {
implementation: HTMLFormElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const parseContentType = require("content-type-parser");
const URL = require("whatwg-url").URL;
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const applyDocumentFeatures = require("../../browser/documentfeatures").applyDocumentFeatures;
const resourceLoader = require("../../browser/resource-loader");
const defineGetter = require("../../utils").defineGetter;
const documentBaseURLSerialized = require("../helpers/document-base-url").documentBaseURLSerialized;
const getAttributeValue = require("../attributes").getAttributeValue;
const idlUtils = require("../generated/utils");
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
function loadFrame(frame) {
if (frame._contentDocument) {
if (frame._contentDocument._defaultView) {
// close calls delete on its document.
frame._contentDocument._defaultView.close();
} else {
delete frame._contentDocument;
}
}
const parentDoc = frame._ownerDocument;
// https://html.spec.whatwg.org/#process-the-iframe-attributes
let url;
const srcAttribute = getAttributeValue(frame, "src");
if (srcAttribute === null || srcAttribute === "") {
url = new URL("about:blank");
} else {
try {
url = new URL(srcAttribute, documentBaseURLSerialized(parentDoc));
} catch (e) {
url = new URL("about:blank");
}
}
// This is not great, but prevents a require cycle during webidl2js generation
const wnd = new parentDoc._defaultView.constructor({
parsingMode: "html",
url: url.protocol === "javascript:" || url.href === "about:blank" ? parentDoc.URL : url.href,
resourceLoader: parentDoc._customResourceLoader,
userAgent: parentDoc._defaultView.navigator.userAgent,
referrer: parentDoc.URL,
cookieJar: parentDoc._cookieJar,
pool: parentDoc._pool,
encoding: parentDoc._encoding,
agentOptions: parentDoc._agentOptions,
strictSSL: parentDoc._strictSSL,
proxy: parentDoc._proxy
});
const contentDoc = frame._contentDocument = idlUtils.implForWrapper(wnd._document);
applyDocumentFeatures(contentDoc, parentDoc._implementation._features);
const parent = parentDoc._defaultView;
const contentWindow = contentDoc._defaultView;
contentWindow._parent = parent;
contentWindow._top = parent.top;
contentWindow._frameElement = frame;
contentWindow._virtualConsole = parent._virtualConsole;
// Handle about:blank with a simulated load of an empty document.
if (url.href === "about:blank") {
// Cannot be done inside the enqueued callback; the documentElement etc. need to be immediately available.
contentDoc.write("<html><head></head><body></body></html>");
contentDoc.close();
resourceLoader.enqueue(frame)(); // to fire the load event
} else if (url.protocol === "javascript:") {
// Cannot be done inside the enqueued callback; the documentElement etc. need to be immediately available.
contentDoc.write("<html><head></head><body></body></html>");
contentDoc.close();
contentWindow.eval(url.pathname);
resourceLoader.enqueue(frame)(); // to fire the load event
} else {
resourceLoader.load(
frame,
url.href,
{ defaultEncoding: parentDoc._encoding, detectMetaCharset: true },
(html, responseURL, response) => {
if (response) {
const contentType = parseContentType(response.headers["content-type"]);
if (contentType) {
if (contentType.isXML()) {
contentDoc._parsingMode = "xml";
}
contentDoc._encoding = contentType.get("charset");
}
}
contentDoc.write(html);
contentDoc.close();
}
);
}
}
function refreshAccessors(document) {
const window = document._defaultView;
if (!window) {
return;
}
const frames = document.querySelectorAll("iframe,frame");
// delete accessors for all frames
for (let i = 0; i < window._length; ++i) {
delete window[i];
}
window._length = frames.length;
Array.prototype.forEach.call(frames, (frame, i) => {
defineGetter(window, i, () => frame.contentWindow);
});
}
class HTMLFrameElementImpl extends HTMLElementImpl {
constructor(args, privateData) {
super(args, privateData);
this._contentDocument = null;
}
_attrModified(name, value, oldVal) {
super._attrModified(name, value, oldVal);
if (name === "src") {
// iframe should never load in a document without a Window
// (e.g. implementation.createHTMLDocument)
if (this._attached && this._ownerDocument._defaultView) {
loadFrame(this);
}
}
}
_detach() {
super._detach();
if (this.contentWindow) {
this.contentWindow.close();
}
refreshAccessors(this._ownerDocument);
}
_attach() {
super._attach();
if (this._ownerDocument._defaultView) {
loadFrame(this);
}
refreshAccessors(this._ownerDocument);
}
get contentDocument() {
return this._contentDocument;
}
get contentWindow() {
return this.contentDocument ? this.contentDocument._defaultView : null;
}
get src() {
return reflectURLAttribute(this, "src");
}
set src(value) {
this.setAttribute("src", value);
}
get longDesc() {
return reflectURLAttribute(this, "longdesc");
}
set longDesc(value) {
this.setAttribute("longdesc", value);
}
}
module.exports = {
implementation: HTMLFrameElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLFramesetElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLFramesetElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLHRElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLHRElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLHeadElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLHeadElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLHeadingElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLHeadingElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLHtmlElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLHtmlElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | 1 1 1 1 1 | "use strict";
const whatwgURL = require("whatwg-url");
const parseURLToResultingURLRecord = require("../helpers/document-base-url").parseURLToResultingURLRecord;
exports.implementation = class HTMLHyperlinkElementUtilsImpl {
_htmlHyperlinkElementUtilsSetup() {
this.url = null;
}
toString() {
return this.href;
}
get href() {
setTheURL(this);
const url = this.url;
if (url === null) {
const href = this.getAttribute("href");
return href === null ? "" : href;
}
return whatwgURL.serializeURL(url);
}
set href(v) {
this.setAttribute("href", v);
}
get origin() {
setTheURL(this);
if (this.url === null) {
return "";
}
return whatwgURL.serializeURLToUnicodeOrigin(this.url);
}
get protocol() {
setTheURL(this);
if (this.url === null) {
return ":";
}
return this.url.scheme + ":";
}
set protocol(v) {
if (this.url === null) {
return;
}
whatwgURL.basicURLParse(v + ":", { url: this.url, stateOverride: "scheme start" });
updateHref(this);
}
get username() {
setTheURL(this);
if (this.url === null) {
return "";
}
return this.url.username;
}
set username(v) {
const url = this.url;
if (url === null || url.host === null || url.cannotBeABaseURL) {
return;
}
whatwgURL.setTheUsername(url, v);
updateHref(this);
}
get password() {
setTheURL(this);
const url = this.url;
if (url === null || url.password === null) {
return "";
}
return url.password;
}
set password(v) {
const url = this.url;
if (url === null || url.host === null || url.cannotBeABaseURL) {
return;
}
whatwgURL.setThePassword(url, v);
updateHref(this);
}
get host() {
setTheURL(this);
const url = this.url;
if (url === null || url.host === null) {
return "";
}
if (url.port === null) {
return whatwgURL.serializeHost(url.host);
}
return whatwgURL.serializeHost(url.host) + ":" + whatwgURL.serializeInteger(url.port);
}
set host(v) {
setTheURL(this);
const url = this.url;
if (url === null || url.cannotBeABaseURL) {
return;
}
whatwgURL.basicURLParse(v, { url, stateOverride: "host" });
updateHref(this);
}
get hostname() {
setTheURL(this);
const url = this.url;
if (url === null || url.host === null) {
return "";
}
return whatwgURL.serializeHost(url.host);
}
set hostname(v) {
setTheURL(this);
const url = this.url;
if (url === null || url.cannotBeABaseURL) {
return;
}
whatwgURL.basicURLParse(v, { url, stateOverride: "hostname" });
updateHref(this);
}
get port() {
setTheURL(this);
const url = this.url;
if (url === null || url.port === null) {
return "";
}
return whatwgURL.serializeInteger(url.port);
}
set port(v) {
setTheURL(this);
const url = this.url;
if (url === null || url.host === null || url.cannotBeABaseURL || url.scheme === "file") {
return;
}
whatwgURL.basicURLParse(v, { url, stateOverride: "port" });
updateHref(this);
}
get pathname() {
setTheURL(this);
const url = this.url;
if (url === null) {
return "";
}
if (url.cannotBeABaseURL) {
return url.path[0];
}
return "/" + url.path.join("/");
}
set pathname(v) {
setTheURL(this);
const url = this.url;
if (url === null || url.cannotBeABaseURL) {
return;
}
url.path = [];
whatwgURL.basicURLParse(v, { url, stateOverride: "path start" });
}
get search() {
setTheURL(this);
const url = this.url;
if (url === null || url.query === null || url.query === "") {
return "";
}
return "?" + url.query;
}
set search(v) {
setTheURL(this);
const url = this.url;
if (url === null) {
return;
}
if (v === "") {
url.query = null;
} else {
const input = v[0] === "?" ? v.substring(1) : v;
url.query = "";
whatwgURL.basicURLParse(input, { url, stateOverride: "query" });
}
updateHref(this);
}
get hash() {
setTheURL(this);
const url = this.url;
if (url === null || url.fragment === null || url.fragment === "") {
return "";
}
return "#" + url.fragment;
}
set hash(v) {
setTheURL(this);
const url = this.url;
if (url === null || url.scheme === "javascript") {
return;
}
if (v === "") {
url.fragment = null;
} else {
const input = v[0] === "#" ? v.substring(1) : v;
url.fragment = "";
whatwgURL.basicURLParse(input, { url, stateOverride: "fragment" });
}
updateHref(this);
}
};
function setTheURL(hheu) {
const href = hheu.getAttribute("href");
if (href === null) {
hheu.url = null;
return;
}
const parsed = parseURLToResultingURLRecord(href, hheu._ownerDocument);
hheu.url = parsed === "failure" ? null : parsed;
}
function updateHref(hheu) {
hheu.setAttribute("href", whatwgURL.serializeURL(hheu.url));
}
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLFrameElementImpl = require("./HTMLFrameElement-impl").implementation;
class HTMLIFrameElementImpl extends HTMLFrameElementImpl { }
module.exports = {
implementation: HTMLIFrameElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const resourceLoader = require("../../browser/resource-loader");
const conversions = require("webidl-conversions");
const Canvas = require("../../utils").Canvas;
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
class HTMLImageElementImpl extends HTMLElementImpl {
_attrModified(name, value, oldVal) {
if (name === "src" && value !== oldVal) {
const document = this._ownerDocument;
if (Canvas && document.implementation._hasFeature("FetchExternalResources", "img")) {
let error;
if (!this._image) {
this._image = new Canvas.Image();
// Install an error handler that just remembers the error. It is then
// thrown in the callback of resourceLoader.load() below.
this._image.onerror = function (err) {
error = err;
};
}
this._currentSrc = null;
resourceLoader.load(this, this.src, {}, (data, url, response) => {
if (response && response.statusCode !== undefined && response.statusCode !== 200) {
throw new Error("Status code: " + response.statusCode);
}
error = null;
this._image.source = data;
if (error) {
throw new Error(error);
}
this._currentSrc = value;
});
} else {
resourceLoader.enqueue(this)();
}
}
super._attrModified(name, value, oldVal);
}
get _accept() {
return "image/png,image/*;q=0.8,*/*;q=0.5";
}
get src() {
return reflectURLAttribute(this, "src");
}
set src(value) {
this.setAttribute("src", value);
}
get height() {
// Just like on browsers, if no width / height is defined, we fall back on the
// dimensions of the internal image data.
return this.hasAttribute("height") ?
conversions["unsigned long"](this.getAttribute("height")) : this.naturalHeight;
}
set height(V) {
this.setAttribute("height", String(V));
}
get width() {
return this.hasAttribute("width") ?
conversions["unsigned long"](this.getAttribute("width")) : this.naturalWidth;
}
set width(V) {
this.setAttribute("width", String(V));
}
get naturalHeight() {
return this._image ? this._image.height : 0;
}
get naturalWidth() {
return this._image ? this._image.width : 0;
}
get complete() {
return Boolean(this._image && this._image.complete);
}
get currentSrc() {
return this._currentSrc || "";
}
}
module.exports = {
implementation: HTMLImageElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const idlUtils = require("../generated/utils");
const Event = require("../generated/Event");
const FileList = require("../generated/FileList");
const DOMException = require("../../web-idl/DOMException");
const internalConstants = require("../helpers/internal-constants");
const domSymbolTree = internalConstants.domSymbolTree;
const cloningSteps = internalConstants.cloningSteps;
const closest = require("../helpers/traversal").closest;
const isDisabled = require("../helpers/form-controls").isDisabled;
const filesSymbol = Symbol("files");
const selectAllowedTypes = new Set(["text", "search", "tel", "url", "password", "email", "date", "month", "week",
"time", "datetime-local", "color", "file", "number"]);
const variableLengthSelectionAllowedTypes = new Set(["text", "search", "tel", "url", "password"]);
function allowSelect(type) {
return selectAllowedTypes.has(type.toLowerCase());
}
function allowVariableLengthSelection(type) {
return variableLengthSelectionAllowedTypes.has(type.toLowerCase());
}
class HTMLInputElementImpl extends HTMLElementImpl {
constructor(args, privateData) {
super(args, privateData);
if (!this.type) {
this.type = "text";
}
this._selectionStart = this._selectionEnd = 0;
this._selectionDirection = "none";
this._value = null;
this._dirtyValue = false;
this._checkedness = false;
this._dirtyCheckedness = false;
// This is used to implement the canceled activation steps for radio inputs:
// "The canceled activation steps consist of setting the checkedness and the element's indeterminate IDL
// attribute back to the values they had before the pre-click activation steps were run."
this._preCancelState = null;
}
_getValue() {
return this._value;
}
_preClickActivationSteps() {
if (this.type === "checkbox") {
this.checked = !this.checked;
} else if (this.type === "radio") {
this._preCancelState = this.checked;
this.checked = true;
}
}
_canceledActivationSteps() {
if (this.type === "checkbox") {
this.checked = !this.checked;
} else if (this.type === "radio") {
if (this._preCancelState !== null) {
this.checked = this._preCancelState;
this._preCancelState = null;
}
}
}
_activationBehavior() {
if (isDisabled(this)) {
return;
}
if (this.type === "checkbox") {
const inputEvent = Event.createImpl(["input", { bubbles: true, cancelable: true }], {});
this.dispatchEvent(inputEvent);
const changeEvent = Event.createImpl(["change", { bubbles: true, cancelable: true }], {});
this.dispatchEvent(changeEvent);
} else if (this.type === "submit") {
const form = this.form;
if (form) {
form._dispatchSubmitEvent();
}
}
}
_attrModified(name) {
const wrapper = idlUtils.wrapperForImpl(this);
if (!this._dirtyValue && name === "value") {
this._value = wrapper.defaultValue;
}
if (!this._dirtyCheckedness && name === "checked") {
this._checkedness = wrapper.defaultChecked;
if (this._checkedness) {
this._removeOtherRadioCheckedness();
}
}
if (name === "name" || name === "type") {
if (this._checkedness) {
this._removeOtherRadioCheckedness();
}
}
super._attrModified.apply(this, arguments);
}
_formReset() {
const wrapper = idlUtils.wrapperForImpl(this);
this._value = wrapper.defaultValue;
this._dirtyValue = false;
this._checkedness = wrapper.defaultChecked;
this._dirtyCheckedness = false;
if (this._checkedness) {
this._removeOtherRadioCheckedness();
}
}
_changedFormOwner() {
if (this._checkedness) {
this._removeOtherRadioCheckedness();
}
}
_removeOtherRadioCheckedness() {
const wrapper = idlUtils.wrapperForImpl(this);
const root = this._radioButtonGroupRoot;
if (!root) {
return;
}
const name = wrapper.name.toLowerCase();
const descendants = domSymbolTree.treeIterator(root);
for (const candidate of descendants) {
if (candidate._radioButtonGroupRoot !== root) {
continue;
}
const candidateWrapper = idlUtils.wrapperForImpl(candidate);
if (!candidateWrapper.name || candidateWrapper.name.toLowerCase() !== name) {
continue;
}
if (candidate !== this) {
candidate._checkedness = false;
}
}
}
get _radioButtonGroupRoot() {
const wrapper = idlUtils.wrapperForImpl(this);
if (this.type !== "radio" || !wrapper.name) {
return null;
}
let e = domSymbolTree.parent(this);
while (e) {
// root node of this home sub tree
// or the form element we belong to
if (!domSymbolTree.parent(e) || e.nodeName.toUpperCase() === "FORM") {
return e;
}
e = domSymbolTree.parent(e);
}
return null;
}
get form() {
return closest(this, "form");
}
get checked() {
return this._checkedness;
}
set checked(checked) {
this._checkedness = Boolean(checked);
this._dirtyCheckedness = true;
if (this._checkedness) {
this._removeOtherRadioCheckedness();
}
}
get value() {
if (this._value === null) {
return "";
}
return this._value;
}
set value(val) {
this._dirtyValue = true;
if (val === null) {
this._value = null;
} else {
this._value = String(val);
}
this._selectionStart = 0;
this._selectionEnd = 0;
this._selectionDirection = "none";
}
get files() {
if (this.type === "file") {
this[filesSymbol] = this[filesSymbol] || FileList.create();
} else {
this[filesSymbol] = null;
}
return this[filesSymbol];
}
get type() {
const type = this.getAttribute("type");
return type ? type.toLowerCase() : "text";
}
set type(type) {
this.setAttribute("type", type);
}
_dispatchSelectEvent() {
const event = this._ownerDocument.createEvent("HTMLEvents");
event.initEvent("select", true, true);
this.dispatchEvent(event);
}
_getValueLength() {
return typeof this.value === "string" ? this.value.length : 0;
}
select() {
if (!allowSelect(this.type)) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
this._selectionStart = 0;
this._selectionEnd = this._getValueLength();
this._selectionDirection = "none";
this._dispatchSelectEvent();
}
get selectionStart() {
if (!allowVariableLengthSelection(this.type)) {
return null;
}
return this._selectionStart;
}
set selectionStart(start) {
if (!allowVariableLengthSelection(this.type)) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
this.setSelectionRange(start, Math.max(start, this._selectionEnd), this._selectionDirection);
}
get selectionEnd() {
if (!allowVariableLengthSelection(this.type)) {
return null;
}
return this._selectionEnd;
}
set selectionEnd(end) {
if (!allowVariableLengthSelection(this.type)) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
this.setSelectionRange(this._selectionStart, end, this._selectionDirection);
}
get selectionDirection() {
if (!allowVariableLengthSelection(this.type)) {
return null;
}
return this._selectionDirection;
}
set selectionDirection(dir) {
if (!allowVariableLengthSelection(this.type)) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
this.setSelectionRange(this._selectionStart, this._selectionEnd, dir);
}
setSelectionRange(start, end, dir) {
if (!allowVariableLengthSelection(this.type)) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
this._selectionEnd = Math.min(end, this._getValueLength());
this._selectionStart = Math.min(start, this._selectionEnd);
this._selectionDirection = dir === "forward" || dir === "backward" ? dir : "none";
this._dispatchSelectEvent();
}
setRangeText(repl, start, end, selectionMode) {
if (!allowVariableLengthSelection(this.type)) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
if (arguments.length < 2) {
start = this._selectionStart;
end = this._selectionEnd;
} else if (start > end) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
start = Math.min(start, this._getValueLength());
end = Math.min(end, this._getValueLength());
const val = this.value;
let selStart = this._selectionStart;
let selEnd = this._selectionEnd;
this.value = val.slice(0, start) + repl + val.slice(end);
const newEnd = start + this.value.length;
if (selectionMode === "select") {
this.setSelectionRange(start, newEnd);
} else if (selectionMode === "start") {
this.setSelectionRange(start, start);
} else if (selectionMode === "end") {
this.setSelectionRange(newEnd, newEnd);
} else { // preserve
const delta = repl.length - (end - start);
if (selStart > end) {
selStart += delta;
} else if (selStart > start) {
selStart = start;
}
if (selEnd > end) {
selEnd += delta;
} else if (selEnd > start) {
selEnd = newEnd;
}
this.setSelectionRange(selStart, selEnd);
}
}
set maxLength(value) {
if (value < 0) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
this.setAttribute("maxlength", String(value));
}
get maxLength() {
if (!this.hasAttribute("maxlength")) {
return 524288; // stole this from chrome
}
return parseInt(this.getAttribute("maxlength"));
}
set minLength(value) {
if (value < 0) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
this.setAttribute("minlength", String(value));
}
get minLength() {
if (!this.hasAttribute("minlength")) {
return 0;
}
return parseInt(this.getAttribute("minlength"));
}
get size() {
if (!this.hasAttribute("size")) {
return 20;
}
return parseInt(this.getAttribute("size"));
}
set size(value) {
if (value <= 0) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
this.setAttribute("size", String(value));
}
[cloningSteps](copy, node) {
copy._value = node._value;
copy._checkedness = node._checkedness;
copy._dirtyValue = node._dirtyValue;
copy._dirtyCheckedness = node._dirtyCheckedness;
}
}
module.exports = {
implementation: HTMLInputElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLLIElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLLIElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 1 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const MouseEvent = require("../generated/MouseEvent");
const closest = require("../helpers/traversal").closest;
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
function isLabelable(node) {
// labelable logic defined at: https://html.spec.whatwg.org/multipage/forms.html#category-label
if (node.nodeType !== 1) {
return false;
}
switch (node.tagName) {
case "BUTTON":
case "KEYGEN":
case "METER":
case "OUTPUT":
case "PROGRESS":
case "SELECT":
case "TEXTAREA":
return true;
case "INPUT":
return node.type !== "hidden";
}
return false;
}
function sendClickToAssociatedNode(node) {
node.dispatchEvent(
MouseEvent.createImpl(["click", {
bubbles: true,
cancelable: true,
view: node.ownerDocument ? node.ownerDocument.defaultView : null,
screenX: 0,
screenY: 0,
clientX: 0,
clientY: 0,
button: 0,
detail: 1,
relatedTarget: null
}])
);
}
class HTMLLabelElementImpl extends HTMLElementImpl {
_activationBehavior() {
if (this.hasAttribute("for")) {
const node = this.ownerDocument.getElementById(this.getAttribute("for"));
if (node && isLabelable(node)) {
sendClickToAssociatedNode(node);
}
} else {
for (const descendant of domSymbolTree.treeIterator(this)) {
if (isLabelable(descendant)) {
sendClickToAssociatedNode(descendant);
break;
}
}
}
}
get form() {
return closest(this, "form");
}
}
module.exports = {
implementation: HTMLLabelElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const closest = require("../helpers/traversal").closest;
class HTMLLegendElementImpl extends HTMLElementImpl {
get form() {
return closest(this, "form");
}
}
module.exports = {
implementation: HTMLLegendElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const LinkStyleImpl = require("./LinkStyle-impl").implementation;
const idlUtils = require("../generated/utils");
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
const fetchStylesheet = require("../helpers/stylesheets").fetchStylesheet;
const parseURLToResultingURLRecord = require("../helpers/document-base-url").parseURLToResultingURLRecord;
const whatwgURL = require("whatwg-url");
// Important reading: "appropriate times to obtain the resource" in
// https://html.spec.whatwg.org/multipage/semantics.html#link-type-stylesheet
class HTMLLinkElementImpl extends HTMLElementImpl {
_attach() {
super._attach();
if (isExternalResourceLink(this)) {
obtainTheResource(this);
}
}
_attrModified(name, value, oldValue) {
super._attrModified(name, value, oldValue);
if (name === "href" && this._attached && isExternalResourceLink(this)) {
obtainTheResource(this);
}
}
get _accept() {
return "text/css,*/*;q=0.1";
}
get href() {
return reflectURLAttribute(this, "href");
}
set href(value) {
this.setAttribute("href", value);
}
}
idlUtils.mixin(HTMLLinkElementImpl.prototype, LinkStyleImpl.prototype);
module.exports = {
implementation: HTMLLinkElementImpl
};
function obtainTheResource(el) {
const href = el.getAttribute("href");
if (href === null || href === "") {
return;
}
const url = parseURLToResultingURLRecord(href, el._ownerDocument);
if (url === "failure") {
return;
}
const serialized = whatwgURL.serializeURL(url);
fetchStylesheet(el, serialized, el.sheet);
}
function isExternalResourceLink(el) {
// for our purposes, only stylesheets can be external resource links
const wrapper = idlUtils.wrapperForImpl(el);
if (!/(?:[ \t\n\r\f]|^)stylesheet(?:[ \t\n\r\f]|$)/i.test(wrapper.rel)) {
// rel is a space-separated list of tokens, and the original rel types
// are case-insensitive.
return false;
}
return Boolean(el.href);
}
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLMapElementImpl extends HTMLElementImpl {
get areas() {
return this.getElementsByTagName("AREA");
}
}
module.exports = {
implementation: HTMLMapElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const notImplemented = require("../../browser/not-implemented");
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
const DOMException = require("../../web-idl/DOMException");
function getTimeRangeDummy() {
return {
length: 0,
start() {
return 0;
},
end() {
return 0;
}
};
}
class HTMLMediaElementImpl extends HTMLElementImpl {
constructor(args, privateData) {
super(args, privateData);
this._muted = false;
this._volume = 1.0;
this.readyState = 0;
this.networkState = 0;
this.currentTime = 0;
this.currentSrc = "";
this.buffered = getTimeRangeDummy();
this.seeking = false;
this.duration = 0;
this.paused = true;
this.played = getTimeRangeDummy();
this.seekable = getTimeRangeDummy();
this.ended = false;
this.audioTracks = [];
this.videoTracks = [];
this.textTracks = [];
}
// Implemented accoring to W3C Draft 22 August 2012
set defaultPlaybackRate(v) {
if (v === 0.0) {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
}
if (this._defaultPlaybackRate !== v) {
this._defaultPlaybackRate = v;
this._dispatchRateChange();
}
}
_dispatchRateChange() {
const ev = this._ownerDocument.createEvent("HTMLEvents");
ev.initEvent("ratechange", false, false);
this.dispatchEvent(ev);
}
get defaultPlaybackRate() {
if (this._defaultPlaybackRate === undefined) {
return 1.0;
}
return this._defaultPlaybackRate;
}
get playbackRate() {
if (this._playbackRate === undefined) {
return 1.0;
}
return this._playbackRate;
}
set playbackRate(v) {
if (v !== this._playbackRate) {
this._playbackRate = v;
this._dispatchRateChange();
}
}
get muted() {
return this._muted;
}
_dispatchVolumeChange() {
const ev = this._ownerDocument.createEvent("HTMLEvents");
ev.initEvent("volumechange", false, false);
this.dispatchEvent(ev);
}
set muted(v) {
if (v !== this._muted) {
this._muted = v;
this._dispatchVolumeChange();
}
}
get defaultMuted() {
return this.getAttribute("muted") !== null;
}
set defaultMuted(v) {
if (v) {
this.setAttribute("muted", v);
} else {
this.removeAttribute("muted");
}
}
get volume() {
return this._volume;
}
set volume(v) {
if (v < 0 || v > 1) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
if (this._volume !== v) {
this._volume = v;
this._dispatchVolumeChange();
}
}
// Not (yet) implemented according to spec
// Should return sane default values
load() {
notImplemented("HTMLMediaElement.prototype.load", this._ownerDocument._defaultView);
}
canPlayType() {
return "";
}
play() {
notImplemented("HTMLMediaElement.prototype.play", this._ownerDocument._defaultView);
}
pause() {
notImplemented("HTMLMediaElement.prototype.pause", this._ownerDocument._defaultView);
}
addTextTrack() {
notImplemented("HTMLMediaElement.prototype.addNextTrack", this._ownerDocument._defaultView);
}
get src() {
return reflectURLAttribute(this, "src");
}
set src(value) {
this.setAttribute("src", value);
}
}
module.exports = {
implementation: HTMLMediaElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLMenuElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLMenuElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLMetaElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLMetaElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLMeterElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLMeterElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLModElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLModElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLOListElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLOListElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
const closest = require("../helpers/traversal").closest;
class HTMLObjectElementImpl extends HTMLElementImpl {
get form() {
return closest(this, "form");
}
get contentDocument() {
return null;
}
get data() {
return reflectURLAttribute(this, "data");
}
set data(V) {
this.setAttribute("data", V);
}
get codeBase() {
return reflectURLAttribute(this, "codebase");
}
set codeBase(V) {
this.setAttribute("codebase", V);
}
}
module.exports = {
implementation: HTMLObjectElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLOptGroupElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLOptGroupElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const idlUtils = require("../generated/utils");
const stripAndCollapseASCIIWhitespace = require("../helpers/strings").stripAndCollapseASCIIWhitespace;
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const closest = require("../helpers/traversal").closest;
class HTMLOptionElementImpl extends HTMLElementImpl {
constructor(args, privateData) {
super(args, privateData);
// whenever selectedness is set to true, make sure all
// other options set selectedness to false
this._selectedness = false;
this._dirtyness = false;
}
_removeOtherSelectedness() {
// Remove the selectedness flag from all other options in this select
const select = this._selectNode;
if (select && !select.hasAttribute("multiple")) {
const o = select.options;
for (let i = 0; i < o.length; i++) {
const option = idlUtils.implForWrapper(o[i]);
if (option !== this) {
option._selectedness = false;
}
}
}
}
_askForAReset() {
const select = this._selectNode;
if (select) {
select._askedForAReset();
}
}
_attrModified(name) {
if (!this._dirtyness && name === "selected") {
const wrapper = idlUtils.wrapperForImpl(this);
this._selectedness = wrapper.defaultSelected;
if (this._selectedness) {
this._removeOtherSelectedness();
}
this._askForAReset();
}
super._attrModified.apply(this, arguments);
}
get _selectNode() {
let select = domSymbolTree.parent(this);
if (!select) {
return null;
}
if (select.nodeName.toUpperCase() !== "SELECT") {
select = domSymbolTree.parent(select);
if (!select || select.nodeName.toUpperCase() !== "SELECT") {
return null;
}
}
return select;
}
get form() {
return closest(this, "form");
}
get text() {
// TODO is not correctly excluding script and SVG script descendants
return stripAndCollapseASCIIWhitespace(this.textContent);
}
set text(V) {
this.textContent = V;
}
get value() {
return this.hasAttribute("value") ? this.getAttribute("value") : this.text;
}
set value(val) {
this.setAttribute("value", val);
}
get index() {
const select = closest(this, "select");
if (select === null) {
return 0;
}
return Array.prototype.indexOf.call(select.options, idlUtils.wrapperForImpl(this));
}
get selected() {
return this._selectedness;
}
set selected(s) {
this._dirtyness = true;
this._selectedness = Boolean(s);
if (this._selectedness) {
this._removeOtherSelectedness();
}
this._askForAReset();
}
// TODO this is quite wrong
get label() {
if (this.hasAttribute("label")) {
return this.getAttribute("label");
}
const select = this._selectNode;
if (select) {
return select.getAttribute("label");
}
return null;
}
set label(V) {
const select = this._selectNode;
if (select) {
select.setAttribute("label", V);
}
}
}
module.exports = {
implementation: HTMLOptionElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLOutputElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLOutputElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLParagraphElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLParagraphElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLParamElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLParamElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLPreElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLPreElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLProgressElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLProgressElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLQuoteElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLQuoteElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const vm = require("vm");
const whatwgEncoding = require("whatwg-encoding");
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
const resourceLoader = require("../../browser/resource-loader");
const reportException = require("../helpers/runtime-script-errors");
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const nodeTypes = require("../node-type");
const jsMIMETypes = new Set([
"application/ecmascript",
"application/javascript",
"application/x-ecmascript",
"application/x-javascript",
"text/ecmascript",
"text/javascript",
"text/javascript1.0",
"text/javascript1.1",
"text/javascript1.2",
"text/javascript1.3",
"text/javascript1.4",
"text/javascript1.5",
"text/jscript",
"text/livescript",
"text/x-ecmascript",
"text/x-javascript"
]);
class HTMLScriptElementImpl extends HTMLElementImpl {
_attach() {
super._attach();
if (this.src) {
resourceLoader.load(
this,
this.src,
{ defaultEncoding: whatwgEncoding.labelToName(this.getAttribute("charset")) || this._ownerDocument._encoding },
this._eval
);
} else if (this.text.trim().length > 0) {
resourceLoader.enqueue(this, this._ownerDocument.URL, this._eval)(null, this.text);
}
}
_attrModified(name, value, oldValue) {
super._attrModified(name, value, oldValue);
if (this._attached && name === "src" && oldValue === null && value !== null) {
resourceLoader.load(
this,
this.src,
{ defaultEncoding: whatwgEncoding.labelToName(this.getAttribute("charset")) || this._ownerDocument._encoding },
this._eval
);
}
}
_eval(text, filename) {
const typeString = this._getTypeString();
if (this._ownerDocument.implementation._hasFeature("ProcessExternalResources", "script") &&
jsMIMETypes.has(typeString.toLowerCase())) {
this._ownerDocument._writeAfterElement = this;
processJavaScript(this, text, filename);
delete this._ownerDocument._writeAfterElement;
}
}
_getTypeString() {
const typeAttr = this.getAttribute("type");
const langAttr = this.getAttribute("language");
if (typeAttr === "") {
return "text/javascript";
}
if (typeAttr === null && langAttr === "") {
return "text/javascript";
}
if (typeAttr === null && langAttr === null) {
return "text/javascript";
}
if (typeAttr !== null) {
return typeAttr.trim();
}
if (langAttr !== null) {
return "text/" + langAttr;
}
return null;
}
get text() {
let text = "";
for (const child of domSymbolTree.childrenIterator(this)) {
if (child.nodeType === nodeTypes.TEXT_NODE) {
text += child.nodeValue;
}
}
return text;
}
set text(text) {
this.textContent = text;
}
get src() {
return reflectURLAttribute(this, "src");
}
set src(V) {
this.setAttribute("src", V);
}
}
function processJavaScript(element, code, filename) {
const document = element.ownerDocument;
const window = document && document._global;
if (window) {
document._currentScript = element;
try {
vm.runInContext(code, window, { filename, displayErrors: false });
} catch (e) {
reportException(window, e, filename);
} finally {
document._currentScript = null;
}
}
}
module.exports = {
implementation: HTMLScriptElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | 1 1 1 1 1 1 1 1 1 | "use strict";
const conversions = require("webidl-conversions");
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const idlUtils = require("../generated/utils");
const NODE_TYPE = require("../node-type");
const createHTMLCollection = require("../html-collection").create;
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const descendantsByHTMLLocalName = require("../helpers/traversal").descendantsByHTMLLocalName;
const closest = require("../helpers/traversal").closest;
class HTMLSelectElementImpl extends HTMLElementImpl {
_formReset() {
Array.prototype.forEach.call(this.options, option => {
const optionImpl = idlUtils.implForWrapper(option);
optionImpl._selectedness = option.defaultSelected;
optionImpl._dirtyness = false;
});
this._askedForAReset();
}
_askedForAReset() {
if (this.hasAttribute("multiple")) {
return;
}
const selected = Array.prototype.filter.call(this.options, option => {
option = idlUtils.implForWrapper(option);
return option._selectedness;
});
// size = 1 is default if not multiple
if ((!this.size || this.size === 1) && !selected.length) {
// select the first option that is not disabled
for (let i = 0; i < this.options.length; ++i) {
const option = idlUtils.implForWrapper(this.options[i]);
let disabled = this.options[i].disabled;
const parentNode = domSymbolTree.parent(option);
if (parentNode &&
parentNode.nodeName.toUpperCase() === "OPTGROUP" &&
idlUtils.wrapperForImpl(parentNode).disabled) {
disabled = true;
}
if (!disabled) {
// (do not set dirty)
option._selectedness = true;
break;
}
}
} else if (selected.length >= 2) {
// select the last selected option
selected.forEach((option, index) => {
option = idlUtils.implForWrapper(option);
option._selectedness = index === selected.length - 1;
});
}
}
_descendantAdded(parent, child) {
if (child.nodeType === NODE_TYPE.ELEMENT_NODE) {
this._askedForAReset();
}
super._descendantAdded.apply(this, arguments);
}
_descendantRemoved(parent, child) {
if (child.nodeType === NODE_TYPE.ELEMENT_NODE) {
this._askedForAReset();
}
super._descendantRemoved.apply(this, arguments);
}
_attrModified(name) {
if (name === "multiple" || name === "size") {
this._askedForAReset();
}
super._attrModified.apply(this, arguments);
}
get options() {
// TODO: implement HTMLOptionsCollection
return createHTMLCollection(this, () => descendantsByHTMLLocalName(this, "option"));
}
get length() {
return this.options.length;
}
get selectedIndex() {
return Array.prototype.reduceRight.call(this.options, (prev, option, i) => {
option = idlUtils.implForWrapper(option);
return option.selected ? i : prev;
}, -1);
}
set selectedIndex(index) {
Array.prototype.forEach.call(this.options, (option, i) => {
option = idlUtils.implForWrapper(option);
option.selected = i === index;
});
}
get value() {
let i = this.selectedIndex;
if (this.options.length && (i === -1)) {
i = 0;
}
if (i === -1) {
return "";
}
return this.options[i].value;
}
set value(val) {
const self = this;
Array.prototype.forEach.call(this.options, option => {
option = idlUtils.implForWrapper(option);
if (option.value === val) {
option.selected = true;
} else if (!self.hasAttribute("multiple")) {
// Remove the selected bit from all other options in this group
// if the multiple attr is not present on the select
option.selected = false;
}
});
}
get form() {
return closest(this, "form");
}
get type() {
return this.hasAttribute("multiple") ? "select-multiple" : "select-one";
}
add(opt, before) {
if (before) {
this.insertBefore(opt, before);
} else {
this.appendChild(opt);
}
}
remove(index) {
const opts = this.options;
if (index >= 0 && index < opts.length) {
const el = idlUtils.implForWrapper(opts[index]);
domSymbolTree.parent(el).removeChild(el);
}
}
get size() {
if (!this.hasAttribute("size")) {
return 0;
}
const size = conversions["unsigned long"](this.getAttribute("size"));
if (isNaN(size)) {
return 0;
}
return size;
}
set size(V) {
this.setAttribute("size", V);
}
}
module.exports = {
implementation: HTMLSelectElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
class HTMLSourceElementImpl extends HTMLElementImpl {
get src() {
return reflectURLAttribute(this, "src");
}
set src(value) {
this.setAttribute("src", value);
}
}
module.exports = {
implementation: HTMLSourceElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLSpanElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLSpanElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1 1 1 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const LinkStyleImpl = require("./LinkStyle-impl").implementation;
const idlUtils = require("../generated/utils");
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const NODE_TYPE = require("../node-type");
const evaluateStylesheet = require("../helpers/stylesheets").evaluateStylesheet;
const documentBaseURL = require("../helpers/document-base-url").documentBaseURL;
class HTMLStyleElementImpl extends HTMLElementImpl {
_attach() {
if (this.type && this.type !== "text/css") {
return;
}
let content = "";
for (const child of domSymbolTree.childrenIterator(this)) {
if (child.nodeType === NODE_TYPE.TEXT_NODE) {
content += child.nodeValue;
}
}
evaluateStylesheet(this, content, this.sheet, documentBaseURL(this._ownerDocument));
super._attach();
}
}
idlUtils.mixin(HTMLStyleElementImpl.prototype, LinkStyleImpl.prototype);
module.exports = {
implementation: HTMLStyleElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLTableCaptionElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLTableCaptionElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const idlUtils = require("../generated/utils");
const closest = require("../helpers/traversal").closest;
const createDOMTokenList = require("../dom-token-list").create;
const resetDOMTokenList = require("../dom-token-list").reset;
class HTMLTableCellImpl extends HTMLElementImpl {
get headers() {
if (this._headers === undefined) {
this._headers = createDOMTokenList(this, "headers");
}
return this._headers;
}
get cellIndex() {
const tr = closest(this, "tr");
if (tr === null) {
return -1;
}
return Array.prototype.indexOf.call(tr.cells, idlUtils.wrapperForImpl(this));
}
get colSpan() {
const value = this.getAttribute("colspan");
return value === null ? 1 : value;
}
set colSpan(V) {
this.setAttribute("colspan", String(V));
}
get rowSpan() {
const value = this.getAttribute("rowspan");
return value === null ? 1 : value;
}
set rowSpan(V) {
this.setAttribute("rowspan", String(V));
}
_attrModified(name, value, oldValue) {
if (name === "headers" && this._headers) {
resetDOMTokenList(this._headers, value);
}
super._attrModified(name, value, oldValue);
}
}
module.exports = {
implementation: HTMLTableCellImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLTableColElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLTableColElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLTableCellElementImpl = require("./HTMLTableCellElement-impl").implementation;
class HTMLTableDataCellElementImpl extends HTMLTableCellElementImpl { }
module.exports = {
implementation: HTMLTableDataCellElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | 1 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const firstChildWithHTMLLocalName = require("../helpers/traversal").firstChildWithHTMLLocalName;
const childrenByHTMLLocalName = require("../helpers/traversal").childrenByHTMLLocalName;
const createHTMLCollection = require("../../living/html-collection").create;
const DOMException = require("../../web-idl/DOMException");
const idlUtils = require("../generated/utils");
class HTMLTableElementImpl extends HTMLElementImpl {
get caption() {
return firstChildWithHTMLLocalName(this, "caption");
}
get tHead() {
return firstChildWithHTMLLocalName(this, "thead");
}
get tFoot() {
return firstChildWithHTMLLocalName(this, "tfoot");
}
get rows() {
if (!this._rows) {
this._rows = createHTMLCollection(this, () => {
const sections = [];
if (this.tHead) {
sections.push(this.tHead);
}
sections.push.apply(sections, childrenByHTMLLocalName(this, "tbody"));
if (this.tFoot) {
sections.push(this.tFoot);
}
if (sections.length === 0) {
return childrenByHTMLLocalName(this, "tr");
}
const rows = [];
for (const s of sections) {
rows.push.apply(rows, childrenByHTMLLocalName(s, "tr"));
}
return rows;
});
}
return this._rows;
}
get tBodies() {
if (!this._tBodies) {
this._tBodies = createHTMLCollection(this, () => childrenByHTMLLocalName(this, "tbody"));
}
return this._tBodies;
}
createTHead() {
let el = this.tHead;
if (!el) {
el = this._ownerDocument.createElement("THEAD");
this.appendChild(el);
}
return el;
}
deleteTHead() {
const el = this.tHead;
if (el) {
el.parentNode.removeChild(el);
}
}
createTFoot() {
let el = this.tFoot;
if (!el) {
el = this._ownerDocument.createElement("TFOOT");
this.appendChild(el);
}
return el;
}
deleteTFoot() {
const el = this.tFoot;
if (el) {
el.parentNode.removeChild(el);
}
}
createCaption() {
let el = this.caption;
if (!el) {
el = this._ownerDocument.createElement("CAPTION");
this.appendChild(el);
}
return el;
}
deleteCaption() {
const c = this.caption;
if (c) {
c.parentNode.removeChild(c);
}
}
insertRow(index) {
if (index < -1 || index > this.rows.length) {
throw new DOMException(DOMException.INDEX_SIZE_ERR,
"Cannot insert a row at an index that is less than -1 or greater than the number of existing rows");
}
const tr = this._ownerDocument.createElement("tr");
if (this.rows.length === 0 && this.tBodies.length === 0) {
const tBody = this._ownerDocument.createElement("tbody");
tBody.appendChild(tr);
this.appendChild(tBody);
} else if (this.rows.length === 0) {
const tBody = idlUtils.implForWrapper(this.tBodies[this.tBodies.length - 1]);
tBody.appendChild(tr);
} else if (index === -1 || index === this.rows.length) {
const tSection = idlUtils.implForWrapper(this.rows[this.rows.length - 1]).parentNode;
tSection.appendChild(tr);
} else {
const beforeTR = idlUtils.implForWrapper(this.rows[index]);
const tSection = beforeTR.parentNode;
tSection.insertBefore(tr, beforeTR);
}
return tr;
}
deleteRow(index) {
if (index === -1) {
index = this.rows.length - 1;
}
if (index < 0 || index >= this.rows.length) {
throw new DOMException(DOMException.INDEX_SIZE_ERR, `Cannot delete a row at index ${index}, where no row exists`);
}
const tr = idlUtils.implForWrapper(this.rows[index]);
tr.parentNode.removeChild(tr);
}
}
module.exports = {
implementation: HTMLTableElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLTableCellElementImpl = require("./HTMLTableCellElement-impl").implementation;
class HTMLTableHeaderCellElementImpl extends HTMLTableCellElementImpl { }
module.exports = {
implementation: HTMLTableHeaderCellElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | 1 1 1 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const idlUtils = require("../generated/utils");
const createHTMLCollection = require("../../living/html-collection").create;
const childrenByHTMLLocalNames = require("../helpers/traversal").childrenByHTMLLocalNames;
const DOMException = require("../../web-idl/DOMException");
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const closest = require("../helpers/traversal").closest;
const cellLocalNames = new Set(["td", "th"]);
class HTMLTableRowElementImpl extends HTMLElementImpl {
get cells() {
if (!this._cells) {
this._cells = createHTMLCollection(this, () => childrenByHTMLLocalNames(this, cellLocalNames));
}
return this._cells;
}
get rowIndex() {
const table = closest(this, "table");
return table ? Array.prototype.indexOf.call(table.rows, idlUtils.wrapperForImpl(this)) : -1;
}
get sectionRowIndex() {
const parent = domSymbolTree.parent(this);
if (parent === null) {
return -1;
}
const rows = parent.rows;
if (!rows) {
return -1;
}
return Array.prototype.indexOf.call(rows, idlUtils.wrapperForImpl(this));
}
insertCell(index) {
const td = this._ownerDocument.createElement("TD");
const cells = this.cells;
if (index < -1 || index > cells.length) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
if (index === -1 || index === cells.length) {
this.appendChild(td);
} else {
const ref = idlUtils.implForWrapper(cells[index]);
this.insertBefore(td, ref);
}
return td;
}
deleteCell(index) {
const cells = this.cells;
if (index === -1) {
index = cells.length - 1;
}
if (index < 0 || index >= cells.length) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
const td = idlUtils.implForWrapper(cells[index]);
this.removeChild(td);
}
}
module.exports = {
implementation: HTMLTableRowElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 1 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const idlUtils = require("../generated/utils");
const childrenByHTMLLocalName = require("../helpers/traversal").childrenByHTMLLocalName;
const createHTMLCollection = require("../../living/html-collection").create;
const DOMException = require("../../web-idl/DOMException");
class HTMLTableSectionElementImpl extends HTMLElementImpl {
get rows() {
if (!this._rows) {
this._rows = createHTMLCollection(this, () => childrenByHTMLLocalName(this, "tr"));
}
return this._rows;
}
insertRow(index) {
if (index < -1 || index > this.rows.length) {
throw new DOMException(DOMException.INDEX_SIZE_ERR,
"Cannot insert a row at an index that is less than -1 or greater than the number of existing rows");
}
const tr = this._ownerDocument.createElement("tr");
if (index === -1 || index === this.rows.length) {
this.appendChild(tr);
} else {
const beforeTR = idlUtils.implForWrapper(this.rows[index]);
this.insertBefore(tr, beforeTR);
}
return tr;
}
deleteRow(index) {
if (index < -1 || index >= this.rows.length) {
throw new DOMException(DOMException.INDEX_SIZE_ERR, `Cannot delete a row at index ${index}, where no row exists`);
}
if (index === -1) {
if (this.rows.length > 0) {
const tr = idlUtils.implForWrapper(this.rows[this.rows.length - 1]);
this.removeChild(tr);
}
} else {
const tr = idlUtils.implForWrapper(this.rows[index]);
this.removeChild(tr);
}
}
}
module.exports = {
implementation: HTMLTableSectionElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const cloningSteps = require("../helpers/internal-constants").cloningSteps;
const clone = require("../node").clone;
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
class HTMLTemplateElementImpl extends HTMLElementImpl {
constructor(args, privateData) {
super(args, privateData);
this._templateContents = this._ownerDocument.createDocumentFragment();
}
get content() {
return this._templateContents;
}
[cloningSteps](copy, node, document, cloneChildren) {
if (!cloneChildren) {
return;
}
for (const child of domSymbolTree.childrenIterator(node._templateContents)) {
const childCopy = clone(this._core, child, copy._templateContents._ownerDocument, true);
copy._templateContents.appendChild(childCopy);
}
}
}
module.exports = {
implementation: HTMLTemplateElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | 1 1 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const DOMException = require("../../web-idl/DOMException");
const closest = require("../helpers/traversal").closest;
const normalizeToCRLF = require("../helpers/form-controls").normalizeToCRLF;
class HTMLTextAreaElement extends HTMLElementImpl {
constructor(args, privateData) {
super(args, privateData);
this._rawValue = "";
this._dirtyValue = false;
}
_formReset() {
this._rawValue = this.textContent;
this._dirtyValue = false;
}
_getAPIValue() {
return this._rawValue.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
}
_getValue() {
// Hard-wrapping omitted, for now.
return normalizeToCRLF(this._rawValue);
}
_modified() {
super._modified();
if (this._dirtyValue === false) {
this._rawValue = this.textContent;
}
}
get form() {
return closest(this, "form");
}
get defaultValue() {
return this.textContent;
}
set defaultValue(val) {
this.textContent = val;
}
get value() {
return this._getAPIValue();
}
set value(val) {
this._rawValue = val;
this._dirtyValue = true;
this._selectionStart = 0;
this._selectionEnd = 0;
this._selectionDirection = "none";
}
get textLength() {
return this.value.length; // code unit length (16 bit)
}
get type() {
return "textarea";
}
_dispatchSelectEvent() {
const event = this._ownerDocument.createEvent("HTMLEvents");
event.initEvent("select", true, true);
this.dispatchEvent(event);
}
_getValueLength() {
return typeof this.value === "string" ? this.value.length : 0;
}
select() {
this._selectionStart = 0;
this._selectionEnd = this._getValueLength();
this._selectionDirection = "none";
this._dispatchSelectEvent();
}
get selectionStart() {
return this._selectionStart;
}
set selectionStart(start) {
this.setSelectionRange(start, Math.max(start, this._selectionEnd), this._selectionDirection);
}
get selectionEnd() {
return this._selectionEnd;
}
set selectionEnd(end) {
this.setSelectionRange(this._selectionStart, end, this._selectionDirection);
}
get selectionDirection() {
return this._selectionDirection;
}
set selectionDirection(dir) {
this.setSelectionRange(this._selectionStart, this._selectionEnd, dir);
}
setSelectionRange(start, end, dir) {
this._selectionEnd = Math.min(end, this._getValueLength());
this._selectionStart = Math.min(start, this._selectionEnd);
this._selectionDirection = dir === "forward" || dir === "backward" ? dir : "none";
this._dispatchSelectEvent();
}
setRangeText(repl, start, end, selectionMode) {
if (arguments.length < 2) {
start = this._selectionStart;
end = this._selectionEnd;
} else if (start > end) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
start = Math.min(start, this._getValueLength());
end = Math.min(end, this._getValueLength());
const val = this.value;
let selStart = this._selectionStart;
let selEnd = this._selectionEnd;
this.value = val.slice(0, start) + repl + val.slice(end);
const newEnd = start + this.value.length;
if (selectionMode === "select") {
this.setSelectionRange(start, newEnd);
} else if (selectionMode === "start") {
this.setSelectionRange(start, start);
} else if (selectionMode === "end") {
this.setSelectionRange(newEnd, newEnd);
} else { // preserve
const delta = repl.length - (end - start);
if (selStart > end) {
selStart += delta;
} else if (selStart > start) {
selStart = start;
}
if (selEnd > end) {
selEnd += delta;
} else if (selEnd > start) {
selEnd = newEnd;
}
this.setSelectionRange(selStart, selEnd);
}
}
get cols() {
if (!this.hasAttribute("cols")) {
return 20;
}
return parseInt(this.getAttribute("cols"));
}
set cols(value) {
if (value <= 0) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
this.setAttribute("cols", String(value));
}
get rows() {
if (!this.hasAttribute("rows")) {
return 2;
}
return parseInt(this.getAttribute("rows"));
}
set rows(value) {
if (value <= 0) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
this.setAttribute("rows", String(value));
}
}
module.exports = {
implementation: HTMLTextAreaElement
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLTimeElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLTimeElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLTitleElementImpl extends HTMLElementImpl {
get text() {
// TODO this is quite incorrect
return this.innerHTML;
}
set text(s) {
this.textContent = s;
}
}
module.exports = {
implementation: HTMLTitleElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
class HTMLTrackElementImpl extends HTMLElementImpl {
get readyState() {
return 0;
}
get src() {
return reflectURLAttribute(this, "src");
}
set src(value) {
this.setAttribute("src", value);
}
}
module.exports = {
implementation: HTMLTrackElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLUListElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLUListElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 1 | "use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
class HTMLUnknownElementImpl extends HTMLElementImpl { }
module.exports = {
implementation: HTMLUnknownElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1 1 1 | "use strict";
const HTMLMediaElementImpl = require("./HTMLMediaElement-impl").implementation;
const reflectURLAttribute = require("../../utils").reflectURLAttribute;
class HTMLVideoElementImpl extends HTMLMediaElementImpl {
get poster() {
return reflectURLAttribute(this, "poster");
}
set poster(value) {
this.setAttribute("poster", value);
}
get videoWidth() {
return 0;
}
get videoHeight() {
return 0;
}
}
module.exports = {
implementation: HTMLVideoElementImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1 1 | "use strict";
const cssom = require("cssom");
class LinkStyleImpl {
get sheet() {
if (!this._cssStyleSheet) {
this._cssStyleSheet = new cssom.CSSStyleSheet();
}
return this._cssStyleSheet;
}
}
module.exports = {
implementation: LinkStyleImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const EventTargetImpl = require("../events/EventTarget-impl").implementation;
const idlUtils = require("../generated/utils");
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const simultaneousIterators = require("../../utils").simultaneousIterators;
const DOMException = require("../../web-idl/DOMException");
const NODE_TYPE = require("../node-type");
const NODE_DOCUMENT_POSITION = require("../node-document-position");
const createLiveNodeList = require("../node-list").createLive;
const updateNodeList = require("../node-list").update;
const updateHTMLCollection = require("../html-collection").update;
const documentBaseURLSerialized = require("../helpers/document-base-url").documentBaseURLSerialized;
const cloneNode = require("../node").clone;
const attributes = require("../attributes");
function isObsoleteNodeType(node) {
return node.nodeType === NODE_TYPE.ENTITY_NODE ||
node.nodeType === NODE_TYPE.ENTITY_REFERENCE_NODE ||
node.nodeType === NODE_TYPE.NOTATION_NODE ||
// node.nodeType === NODE_TYPE.ATTRIBUTE_NODE || // this is missing how do we handle?
node.nodeType === NODE_TYPE.CDATA_SECTION_NODE;
}
function nodeEquals(a, b) {
if (a.nodeType !== b.nodeType) {
return false;
}
switch (a.nodeType) {
case NODE_TYPE.DOCUMENT_TYPE_NODE:
if (a.name !== b.name || a.publicId !== b.publicId ||
a.systemId !== b.systemId) {
return false;
}
break;
case NODE_TYPE.ELEMENT_NODE:
if (a._namespaceURI !== b._namespaceURI || a._prefix !== b._prefix || a._localName !== b._localName ||
a._attributes.length !== b._attributes.length) {
return false;
}
break;
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
if (a._target !== b._target || a._data !== b._data) {
return false;
}
break;
case NODE_TYPE.TEXT_NODE:
case NODE_TYPE.COMMENT_NODE:
if (a._data !== b._data) {
return false;
}
break;
}
if (a.nodeType === NODE_TYPE.ELEMENT_NODE && !attributes.attributeListsEqual(a, b)) {
return false;
}
for (const nodes of simultaneousIterators(domSymbolTree.childrenIterator(a), domSymbolTree.childrenIterator(b))) {
if (!nodes[0] || !nodes[1]) {
// mismatch in the amount of childNodes
return false;
}
if (!nodeEquals(nodes[0], nodes[1])) {
return false;
}
}
return true;
}
class NodeImpl extends EventTargetImpl {
constructor(args, privateData) {
super();
domSymbolTree.initialize(this);
this._core = privateData.core;
this._ownerDocument = privateData.ownerDocument;
this._childNodesList = null;
this._childrenList = null;
this._version = 0;
this._memoizedQueries = {};
}
get nodeValue() {
if (this.nodeType === NODE_TYPE.TEXT_NODE ||
this.nodeType === NODE_TYPE.COMMENT_NODE ||
this.nodeType === NODE_TYPE.CDATA_SECTION_NODE ||
this.nodeType === NODE_TYPE.PROCESSING_INSTRUCTION_NODE) {
return this._data;
}
return null;
}
set nodeValue(value) {
if (this.nodeType === NODE_TYPE.TEXT_NODE ||
this.nodeType === NODE_TYPE.COMMENT_NODE ||
this.nodeType === NODE_TYPE.CDATA_SECTION_NODE ||
this.nodeType === NODE_TYPE.PROCESSING_INSTRUCTION_NODE) {
this.replaceData(0, this.length, value);
}
}
get parentNode() {
return domSymbolTree.parent(this);
}
get nodeName() {
switch (this.nodeType) {
case NODE_TYPE.ELEMENT_NODE:
return this.tagName;
case NODE_TYPE.TEXT_NODE:
return "#text";
case NODE_TYPE.CDATA_SECTION_NODE:
return "#cdata-section";
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
return this.target;
case NODE_TYPE.COMMENT_NODE:
return "#comment";
case NODE_TYPE.DOCUMENT_NODE:
return "#document";
case NODE_TYPE.DOCUMENT_TYPE_NODE:
return this.name;
case NODE_TYPE.DOCUMENT_FRAGMENT_NODE:
return "#document-fragment";
}
// should never happen
return null;
}
get firstChild() {
return domSymbolTree.firstChild(this);
}
get ownerDocument() {
return this.nodeType === NODE_TYPE.DOCUMENT_NODE ? null : this._ownerDocument;
}
get lastChild() {
return domSymbolTree.lastChild(this);
}
get childNodes() {
if (!this._childNodesList) {
this._childNodesList = createLiveNodeList(this, () => domSymbolTree.childrenToArray(this));
} else {
updateNodeList(this._childNodesList);
}
return this._childNodesList;
}
get nextSibling() {
return domSymbolTree.nextSibling(this);
}
get previousSibling() {
return domSymbolTree.previousSibling(this);
}
insertBefore(newChildImpl, refChildImpl) {
// TODO branding
if (!newChildImpl || !(newChildImpl instanceof NodeImpl)) {
throw new TypeError("First argument to Node.prototype.insertBefore must be a Node");
}
if (refChildImpl !== null && !(refChildImpl instanceof NodeImpl)) {
throw new TypeError("Second argument to Node.prototype.insertBefore must be a Node or null or undefined");
}
// DocumentType must be implicitly adopted
if (newChildImpl.nodeType === NODE_TYPE.DOCUMENT_TYPE_NODE) {
newChildImpl._ownerDocument = this._ownerDocument;
}
if (newChildImpl.nodeType && newChildImpl.nodeType === NODE_TYPE.ATTRIBUTE_NODE) {
throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
if (this._ownerDocument !== newChildImpl._ownerDocument) {
// adopt the node when it's not in this document
this._ownerDocument.adoptNode(newChildImpl);
} else {
// search for parents matching the newChild
for (const ancestor of domSymbolTree.ancestorsIterator(this)) {
if (ancestor === newChildImpl) {
throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
}
}
// fragments are merged into the element (except parser-created fragments in <template>)
if (newChildImpl.nodeType === NODE_TYPE.DOCUMENT_FRAGMENT_NODE) {
let grandChildImpl;
while ((grandChildImpl = domSymbolTree.firstChild(newChildImpl))) {
newChildImpl.removeChild(grandChildImpl);
this.insertBefore(grandChildImpl, refChildImpl);
}
} else if (newChildImpl === refChildImpl) {
return newChildImpl;
} else {
const oldParentImpl = domSymbolTree.parent(newChildImpl);
// if the newChild is already in the tree elsewhere, remove it first
if (oldParentImpl) {
oldParentImpl.removeChild(newChildImpl);
}
if (refChildImpl === null) {
domSymbolTree.appendChild(this, newChildImpl);
} else {
if (domSymbolTree.parent(refChildImpl) !== this) {
throw new DOMException(DOMException.NOT_FOUND_ERR);
}
domSymbolTree.insertBefore(refChildImpl, newChildImpl);
}
this._modified();
if (this._attached && newChildImpl._attach) {
newChildImpl._attach();
}
this._descendantAdded(this, newChildImpl);
}
return newChildImpl;
} // raises(DOMException);
_modified() {
this._version++;
for (const ancestor of domSymbolTree.ancestorsIterator(this)) {
ancestor._version++;
}
if (this._childrenList) {
updateHTMLCollection(this._childrenList);
}
if (this._childNodesList) {
updateNodeList(this._childNodesList);
}
this._clearMemoizedQueries();
}
_clearMemoizedQueries() {
this._memoizedQueries = {};
const myParent = domSymbolTree.parent(this);
if (myParent) {
myParent._clearMemoizedQueries();
}
}
_descendantRemoved(parent, child) {
const myParent = domSymbolTree.parent(this);
if (myParent) {
myParent._descendantRemoved(parent, child);
}
}
_descendantAdded(parent, child) {
const myParent = domSymbolTree.parent(this);
if (myParent) {
myParent._descendantAdded(parent, child);
}
}
replaceChild(node, child) {
if (arguments.length < 2) {
throw new TypeError("Not enough arguments to Node.prototype.replaceChild");
}
// TODO branding
if (!node || !(node instanceof NodeImpl)) {
throw new TypeError("First argument to Node.prototype.replaceChild must be a Node");
}
if (!child || !(child instanceof NodeImpl)) {
throw new TypeError("Second argument to Node.prototype.replaceChild must be a Node");
}
this.insertBefore(node, child);
return this.removeChild(child);
}
_attach() {
this._attached = true;
for (const child of domSymbolTree.childrenIterator(this)) {
if (child._attach) {
child._attach();
}
}
}
_detach() {
this._attached = false;
if (this._ownerDocument && this._ownerDocument._lastFocusedElement === this) {
this._ownerDocument._lastFocusedElement = null;
}
for (const child of domSymbolTree.childrenIterator(this)) {
if (child._detach) {
child._detach();
}
}
}
removeChild(/* Node */ oldChildImpl) {
if (!oldChildImpl || domSymbolTree.parent(oldChildImpl) !== this) {
throw new DOMException(DOMException.NOT_FOUND_ERR);
}
const oldPreviousSibling = oldChildImpl.previousSibling;
domSymbolTree.remove(oldChildImpl);
this._modified();
oldChildImpl._detach();
this._descendantRemoved(this, oldChildImpl);
if (this._ownerDocument) {
this._ownerDocument._runRemovingSteps(oldChildImpl, this, oldPreviousSibling);
}
return oldChildImpl;
} // raises(DOMException);
appendChild(newChild) {
if (!("nodeType" in newChild)) {
throw new TypeError("First argument to Node.prototype.appendChild must be a Node");
}
return this.insertBefore(newChild, null);
}
hasChildNodes() {
return domSymbolTree.hasChildren(this);
}
normalize() {
for (const child of domSymbolTree.childrenIterator(this)) {
if (child.normalize) {
child.normalize();
}
if (child.nodeValue === "") {
this.removeChild(child);
continue;
}
const prevChild = domSymbolTree.previousSibling(child);
if (prevChild && prevChild.nodeType === NODE_TYPE.TEXT_NODE && child.nodeType === NODE_TYPE.TEXT_NODE) {
// merge text nodes
prevChild.appendData(child.nodeValue);
this.removeChild(child);
}
}
}
get parentElement() {
const parentNode = domSymbolTree.parent(this);
return parentNode !== null && parentNode.nodeType === NODE_TYPE.ELEMENT_NODE ? parentNode : null;
}
get baseURI() {
return documentBaseURLSerialized(this._ownerDocument);
}
compareDocumentPosition(otherImpl) {
// Let reference be the context object.
const reference = this;
if (!(otherImpl instanceof NodeImpl)) {
throw new Error("Comparing position against non-Node values is not allowed");
}
if (isObsoleteNodeType(reference) || isObsoleteNodeType(otherImpl)) {
throw new Error("Obsolete node type");
}
const result = domSymbolTree.compareTreePosition(reference, otherImpl);
// “If other and reference are not in the same tree, return the result of adding DOCUMENT_POSITION_DISCONNECTED,
// DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, and either DOCUMENT_POSITION_PRECEDING or
// DOCUMENT_POSITION_FOLLOWING, with the constraint that this is to be consistent, together.”
if (result === NODE_DOCUMENT_POSITION.DOCUMENT_POSITION_DISCONNECTED) {
// symbol-tree does not add these bits required by the spec:
return NODE_DOCUMENT_POSITION.DOCUMENT_POSITION_DISCONNECTED |
NODE_DOCUMENT_POSITION.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC |
NODE_DOCUMENT_POSITION.DOCUMENT_POSITION_FOLLOWING;
}
return result;
}
contains(other) {
if (!(other instanceof NodeImpl)) {
return false;
} else if (this === other) {
return true;
}
return Boolean(this.compareDocumentPosition(other) & NODE_DOCUMENT_POSITION.DOCUMENT_POSITION_CONTAINED_BY);
}
isEqualNode(node) {
if (node === null) {
return false;
}
// Fast-path, not in the spec
if (this === node) {
return true;
}
return nodeEquals(this, node);
}
cloneNode(deep) {
deep = Boolean(deep);
return cloneNode(this._core, this, undefined, deep);
}
get textContent() {
let text;
switch (this.nodeType) {
case NODE_TYPE.COMMENT_NODE:
case NODE_TYPE.CDATA_SECTION_NODE:
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
case NODE_TYPE.TEXT_NODE:
return this.nodeValue;
case NODE_TYPE.ATTRIBUTE_NODE:
case NODE_TYPE.DOCUMENT_FRAGMENT_NODE:
case NODE_TYPE.ELEMENT_NODE:
text = "";
for (const child of domSymbolTree.treeIterator(this)) {
if (child.nodeType === NODE_TYPE.TEXT_NODE || child.nodeType === NODE_TYPE.CDATA_SECTION_NODE) {
text += child.nodeValue;
}
}
return text;
default:
return null;
}
}
set textContent(txt) {
switch (this.nodeType) {
case NODE_TYPE.COMMENT_NODE:
case NODE_TYPE.CDATA_SECTION_NODE:
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
case NODE_TYPE.TEXT_NODE:
this.nodeValue = String(txt);
return;
}
let child = domSymbolTree.firstChild(this);
while (child) {
this.removeChild(child);
child = domSymbolTree.firstChild(this);
}
if (txt !== "" && txt !== null) {
this.appendChild(this._ownerDocument.createTextNode(txt));
}
}
toString() {
const wrapper = idlUtils.wrapperForImpl(this);
return `[object ${wrapper.constructor.name}]`;
}
}
module.exports = {
implementation: NodeImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 1 1 1 | "use strict";
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const NODE_TYPE = require("../node-type");
class NonDocumentTypeChildNodeImpl {
get nextElementSibling() {
for (const sibling of domSymbolTree.nextSiblingsIterator(this)) {
if (sibling.nodeType === NODE_TYPE.ELEMENT_NODE) {
return sibling;
}
}
return null;
}
get previousElementSibling() {
for (const sibling of domSymbolTree.previousSiblingsIterator(this)) {
if (sibling.nodeType === NODE_TYPE.ELEMENT_NODE) {
return sibling;
}
}
return null;
}
}
module.exports = {
implementation: NonDocumentTypeChildNodeImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 | "use strict";
class NonElementParentNodeImpl {
}
module.exports = {
implementation: NonElementParentNodeImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const idlUtils = require("../generated/utils");
const nwmatcher = require("nwmatcher/src/nwmatcher-noqsa");
const DOMException = require("../../web-idl/DOMException");
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const NODE_TYPE = require("../node-type");
const createHTMLCollection = require("../html-collection").create;
const updateHTMLCollection = require("../html-collection").update;
const memoizeQuery = require("../../utils").memoizeQuery;
const createStaticNodeList = require("../node-list").createStatic;
// nwmatcher gets `document.documentElement` at creation-time, so we have to initialize lazily, since in the initial
// stages of Document initialization, there is no documentElement present yet.
function addNwmatcher(parentNode) {
const document = parentNode._ownerDocument;
if (!document._nwmatcher) {
document._nwmatcher = nwmatcher({ document });
document._nwmatcher.configure({ UNIQUE_ID: false });
}
return document._nwmatcher;
}
class ParentNodeImpl {
get children() {
if (!this._childrenList) {
this._childrenList = createHTMLCollection(this, () => {
return domSymbolTree.childrenToArray(this, { filter(node) {
return node.nodeType === NODE_TYPE.ELEMENT_NODE;
} });
});
} else {
updateHTMLCollection(this._childrenList);
}
return this._childrenList;
}
get firstElementChild() {
for (const child of domSymbolTree.childrenIterator(this)) {
if (child.nodeType === NODE_TYPE.ELEMENT_NODE) {
return child;
}
}
return null;
}
get lastElementChild() {
for (const child of domSymbolTree.childrenIterator(this, { reverse: true })) {
if (child.nodeType === NODE_TYPE.ELEMENT_NODE) {
return child;
}
}
return null;
}
get childElementCount() {
return this.children.length;
}
}
ParentNodeImpl.prototype.querySelector = memoizeQuery(function (selectors) {
const matcher = addNwmatcher(this);
try {
return matcher.first(selectors, idlUtils.wrapperForImpl(this));
} catch (e) {
throw new DOMException(DOMException.SYNTAX_ERR, e.message);
}
});
ParentNodeImpl.prototype.querySelectorAll = memoizeQuery(function (selectors) {
const matcher = addNwmatcher(this);
let list;
try {
list = matcher.select(selectors, idlUtils.wrapperForImpl(this));
} catch (e) {
throw new DOMException(DOMException.SYNTAX_ERR, e.message);
}
return createStaticNodeList(list);
});
module.exports = {
implementation: ParentNodeImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1 1 1 | "use strict";
const CharacterDataImpl = require("./CharacterData-impl").implementation;
const NODE_TYPE = require("../node-type");
class ProcessingInstructionImpl extends CharacterDataImpl {
constructor(args, privateData) {
super(args, privateData);
this.nodeType = NODE_TYPE.PROCESSING_INSTRUCTION_NODE;
this._target = privateData.target;
}
get target() {
return this._target;
}
}
module.exports = {
implementation: ProcessingInstructionImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 1 1 1 1 1 | "use strict";
const CharacterDataImpl = require("./CharacterData-impl").implementation;
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const DOMException = require("../../web-idl/DOMException");
const NODE_TYPE = require("../node-type");
class TextImpl extends CharacterDataImpl {
constructor(args, privateData) {
super(args, privateData);
this.nodeType = NODE_TYPE.TEXT_NODE;
}
splitText(offset) {
offset >>>= 0;
const length = this.length;
if (offset > length) {
throw new DOMException(DOMException.INDEX_SIZE_ERR);
}
const count = length - offset;
const newData = this.substringData(offset, count);
const newNode = this._ownerDocument.createTextNode(newData);
const parent = domSymbolTree.parent(this);
if (parent !== null) {
parent.insertBefore(newNode, this.nextSibling);
}
this.replaceData(offset, count, "");
return newNode;
// TODO: range stuff
}
get wholeText() {
let wholeText = this.textContent;
let next;
let current = this;
while ((next = domSymbolTree.previousSibling(current)) && next.nodeType === NODE_TYPE.TEXT_NODE) {
wholeText = next.textContent + wholeText;
current = next;
}
current = this;
while ((next = domSymbolTree.nextSibling(current)) && next.nodeType === NODE_TYPE.TEXT_NODE) {
wholeText += next.textContent;
current = next;
}
return wholeText;
}
}
module.exports = {
implementation: TextImpl
};
|
| 1 2 3 4 5 6 7 8 9 10 11 | 1 | "use strict";
class WindowEventHandlersImpl {
}
module.exports = {
implementation: WindowEventHandlersImpl
};
|
| 1 2 3 4 5 6 | 1 1 | "use strict";
const DocumentImpl = require("./Document-impl").implementation;
exports.implementation = class XMLDocumentImpl extends DocumentImpl {};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| TreeWalker-impl.js | 9.68% | (12 / 124) | 0% | (0 / 79) | 0% | (0 / 15) | 9.76% | (12 / 123) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const DOMException = require("../../web-idl/DOMException");
const idlUtils = require("../generated/utils");
const conversions = require("webidl-conversions");
// FIXME: Once NodeFilter is ported to IDL method, uncomment these.
const FILTER_ACCEPT = 1; // NodeFilter.FILTER_ACCEPT;
const FILTER_REJECT = 2; // NodeFilter.FILTER_REJECT;
const FILTER_SKIP = 3; // NodeFilter.FILTER_SKIP;
const FIRST = false;
const LAST = true;
const NEXT = false;
const PREVIOUS = true;
function isNull(o) {
return o === null || typeof o === "undefined";
}
class TreeWalkerImpl {
constructor(args, privateData) {
this.root = privateData.root;
this.whatToShow = privateData.whatToShow;
this.filter = privateData.filter;
this.currentNode = this.root;
}
get currentNode() {
return this._currentNode;
}
set currentNode(node) {
if (isNull(node)) {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Cannot set currentNode to null");
}
this._currentNode = node;
}
parentNode() {
let node = this._currentNode;
while (!isNull(node) && node !== this.root) {
node = node.parentNode;
if (!isNull(node) && this._filterNode(node) === FILTER_ACCEPT) {
return (this._currentNode = node);
}
}
return null;
}
firstChild() {
return this._traverseChildren(FIRST);
}
lastChild() {
return this._traverseChildren(LAST);
}
previousSibling() {
return this._traverseSiblings(PREVIOUS);
}
nextSibling() {
return this._traverseSiblings(NEXT);
}
previousNode() {
let node = this._currentNode;
while (node !== this.root) {
let sibling = node.previousSibling;
while (!isNull(sibling)) {
node = sibling;
let result = this._filterNode(node);
while (result !== FILTER_REJECT && node.hasChildNodes()) {
node = node.lastChild;
result = this._filterNode(node);
}
if (result === FILTER_ACCEPT) {
return (this._currentNode = node);
}
sibling = node.previousSibling;
}
if (node === this.root || isNull(node.parentNode)) {
return null;
}
node = node.parentNode;
if (this._filterNode(node) === FILTER_ACCEPT) {
return (this._currentNode = node);
}
}
return null;
}
nextNode() {
let node = this._currentNode;
let result = FILTER_ACCEPT;
for (;;) {
while (result !== FILTER_REJECT && node.hasChildNodes()) {
node = node.firstChild;
result = this._filterNode(node);
if (result === FILTER_ACCEPT) {
return (this._currentNode = node);
}
}
do {
if (node === this.root) {
return null;
}
const sibling = node.nextSibling;
if (!isNull(sibling)) {
node = sibling;
break;
}
node = node.parentNode;
} while (!isNull(node));
if (isNull(node)) {
return null;
}
result = this._filterNode(node);
if (result === FILTER_ACCEPT) {
return (this._currentNode = node);
}
}
}
toString() {
return "[object TreeWalker]";
}
_filterNode(node) {
const n = node.nodeType - 1;
if (!((1 << n) & this.whatToShow)) {
return FILTER_SKIP;
}
const filter = this.filter;
if (isNull(filter)) {
return FILTER_ACCEPT;
}
let result;
if (typeof filter === "function") {
result = filter(idlUtils.wrapperForImpl(node));
} else {
result = filter.acceptNode(idlUtils.wrapperForImpl(node));
}
result = conversions["unsigned short"](result);
return result;
}
_traverseChildren(type) {
let node = this._currentNode;
node = type === FIRST ? node.firstChild : node.lastChild;
if (isNull(node)) {
return null;
}
main: for (;;) {
const result = this._filterNode(node);
if (result === FILTER_ACCEPT) {
return (this._currentNode = node);
}
if (result === FILTER_SKIP) {
const child = type === FIRST ? node.firstChild : node.lastChild;
if (!isNull(child)) {
node = child;
continue;
}
}
for (;;) {
const sibling = type === FIRST ? node.nextSibling : node.previousSibling;
if (!isNull(sibling)) {
node = sibling;
continue main;
}
const parent = node.parentNode;
if (isNull(parent) || parent === this.root || parent === this._currentNode) {
return null;
}
node = parent;
}
}
}
_traverseSiblings(type) {
let node = this._currentNode;
if (node === this.root) {
return null;
}
for (;;) {
let sibling = type === NEXT ? node.nextSibling : node.previousSibling;
while (!isNull(sibling)) {
node = sibling;
const result = this._filterNode(node);
if (result === FILTER_ACCEPT) {
return (this._currentNode = node);
}
sibling = type === NEXT ? node.firstChild : node.lastChild;
if (result === FILTER_REJECT || isNull(sibling)) {
sibling = type === NEXT ? node.nextSibling : node.previousSibling;
}
}
node = node.parentNode;
if (isNull(node) || node === this.root) {
return null;
}
if (this._filterNode(node) === FILTER_ACCEPT) {
return null;
}
}
}
}
module.exports = {
implementation: TreeWalkerImpl
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| History-impl.js | 8.47% | (5 / 59) | 0% | (0 / 22) | 0% | (0 / 12) | 8.62% | (5 / 58) | |
| Location-impl.js | 7.37% | (7 / 95) | 0% | (0 / 51) | 0% | (0 / 25) | 7.37% | (7 / 95) | |
| navigation.js | 19.15% | (9 / 47) | 0% | (0 / 24) | 0% | (0 / 1) | 19.15% | (9 / 47) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | 1 1 1 1 1 | "use strict";
const DOMException = require("../../web-idl/DOMException.js");
const documentBaseURLSerialized = require("../helpers/document-base-url.js").documentBaseURLSerialized;
const parseURLToResultingURLRecord = require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const traverseHistory = require("./navigation.js").traverseHistory;
exports.implementation = class HistoryImpl {
constructor(args, privateData) {
this._window = privateData.window;
this._document = privateData.document;
this._actAsIfLocationReloadCalled = privateData.actAsIfLocationReloadCalled;
this._state = null;
this._latestEntry = null;
this._historyTraversalQueue = new Set();
}
_guardAgainstInactiveDocuments() {
if (!this._window) {
throw new DOMException(DOMException.SECURITY_ERR,
"History object is associated with a document that is not fully active.");
}
}
get length() {
this._guardAgainstInactiveDocuments();
return this._window._sessionHistory.length;
}
get state() {
this._guardAgainstInactiveDocuments();
return this._state;
}
go(delta) {
this._guardAgainstInactiveDocuments();
if (delta === 0) {
this._actAsIfLocationReloadCalled();
} else {
this._queueHistoryTraversalTask(() => {
const newIndex = this._window._currentSessionHistoryEntryIndex + delta;
if (newIndex < 0 || newIndex >= this._window._sessionHistory.length) {
return;
}
const specifiedEntry = this._window._sessionHistory[newIndex];
// Not implemented: unload a document guard
// Not clear that this should be queued. html/browsers/history/the-history-interface/004.html can be fixed
// by removing the queue, but doing so breaks some tests in history.js that also pass in browsers.
this._queueHistoryTraversalTask(() => traverseHistory(this._window, specifiedEntry));
});
}
}
back() {
this.go(-1);
}
forward() {
this.go(+1);
}
pushState(data, title, url) {
this._sharedPushAndReplaceState(data, title, url, "pushState");
}
replaceState(data, title, url) {
this._sharedPushAndReplaceState(data, title, url, "replaceState");
}
_sharedPushAndReplaceState(data, title, url, methodName) {
this._guardAgainstInactiveDocuments();
// TODO structured clone data
let newURL;
if (url !== null) {
// Not implemented: use of entry settings object's API base URL. Instead we just use the document base URL. The
// difference matters in the case of cross-frame calls.
newURL = parseURLToResultingURLRecord(url, this._document);
if (newURL === "failure") {
throw new DOMException(DOMException.SECURITY_ERR, `Could not parse url argument "${url}" to ${methodName} ` +
`against base URL "${documentBaseURLSerialized(this._document)}".`);
}
if (newURL.scheme !== this._document._URL.scheme ||
newURL.username !== this._document._URL.username ||
newURL.password !== this._document._URL.password ||
newURL.host !== this._document._URL.host ||
newURL.port !== this._document._URL.port ||
newURL.cannotBeABaseURL !== this._document._URL.cannotBeABaseURL) {
throw new DOMException(DOMException.SECURITY_ERR, `${methodName} cannot update history to a URL which ` +
`differs in components other than in path, query, or fragment.`);
}
// Not implemented: origin check (seems to only apply to documents with weird origins, e.g. sandboxed ones)
} else {
newURL = this._window._sessionHistory[this._window._currentSessionHistoryEntryIndex].url;
}
if (methodName === "pushState") {
this._window._sessionHistory.splice(this._window._currentSessionHistoryEntryIndex + 1, Infinity);
this._clearHistoryTraversalTasks();
this._window._sessionHistory.push({
document: this._document,
stateObject: data,
title,
url: newURL
});
this._window._currentSessionHistoryEntryIndex = this._window._sessionHistory.length - 1;
} else {
const currentEntry = this._window._sessionHistory[this._window._currentSessionHistoryEntryIndex];
currentEntry.stateObject = data;
currentEntry.title = title;
currentEntry.url = newURL;
}
this._document._URL = newURL;
this._state = data; // TODO clone again!! O_o
this._latestEntry = this._window._sessionHistory[this._window._currentSessionHistoryEntryIndex];
}
_queueHistoryTraversalTask(fn) {
const timeoutId = this._window.setTimeout(() => {
this._historyTraversalQueue.delete(timeoutId);
fn();
}, 0);
this._historyTraversalQueue.add(timeoutId);
}
_clearHistoryTraversalTasks() {
for (const timeoutId of this._historyTraversalQueue) {
this._window.clearTimeout(timeoutId);
}
this._historyTraversalQueue.clear();
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | 1 1 1 1 1 1 1 | "use strict";
const whatwgURL = require("whatwg-url");
const documentBaseURL = require("../helpers/document-base-url.js").documentBaseURL;
const parseURLToResultingURLRecord = require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const DOMException = require("../../web-idl/DOMException.js");
const notImplemented = require("../../browser/not-implemented.js");
const navigate = require("./navigation.js").navigate;
// Not implemented: use of entry settings object's API base URL in href setter, assign, and replace. Instead we just
// use the document base URL. The difference matters in the case of cross-frame calls.
exports.implementation = class LocationImpl {
constructor(args, privateData) {
this._relevantDocument = privateData.relevantDocument;
this.url = null;
}
get _url() {
return this._relevantDocument._URL;
}
_locationObjectSetterNavigate(url) {
// Not implemented: extra steps here to determine replacement flag, since they are not applicable to our
// rudimentary "navigation" implementation.
return this._locationObjectNavigate(url);
}
_locationObjectNavigate(url/* , { replacement = false } = {} */) {
// Not implemented: the setup for calling navigate, which doesn't apply to our stub navigate anyway.
// Not implemented: using the replacement flag.
navigate(this._relevantDocument._defaultView, url);
}
toString() {
return this.href;
}
get href() {
return whatwgURL.serializeURL(this._url);
}
set href(v) {
const newURL = whatwgURL.parseURL(v, { baseURL: documentBaseURL(this._relevantDocument) });
if (newURL === "failure") {
throw new TypeError(`Could not parse "${v}" as a URL`);
}
this._locationObjectSetterNavigate(newURL);
}
get origin() {
return whatwgURL.serializeURLToUnicodeOrigin(this._url);
}
get protocol() {
return this._url.scheme + ":";
}
set protocol(v) {
const copyURL = Object.assign({}, this._url);
const possibleFailure = whatwgURL.basicURLParse(v + ":", { url: copyURL, stateOverride: "scheme start" });
if (possibleFailure === "failure") {
throw new TypeError(`Could not parse the URL after setting the procol to "${v}"`);
}
if (copyURL.scheme !== "http" && copyURL.scheme !== "https") {
return;
}
this._locationObjectSetterNavigate(copyURL);
}
get host() {
const url = this._url;
if (url.host === null) {
return "";
}
if (url.port === null) {
return whatwgURL.serializeHost(url.host);
}
return whatwgURL.serializeHost(url.host) + ":" + whatwgURL.serializeInteger(url.port);
}
set host(v) {
const copyURL = Object.assign({}, this._url);
if (copyURL.cannotBeABaseURL) {
return;
}
whatwgURL.basicURLParse(v, { url: copyURL, stateOverride: "host" });
this._locationObjectSetterNavigate(copyURL);
}
get hostname() {
if (this._url.host === null) {
return "";
}
return whatwgURL.serializeHost(this._url.host);
}
set hostname(v) {
const copyURL = Object.assign({}, this._url);
if (copyURL.cannotBeABaseURL) {
return;
}
whatwgURL.basicURLParse(v, { url: copyURL, stateOverride: "hostname" });
this._locationObjectSetterNavigate(copyURL);
}
get port() {
if (this._url.port === null) {
return "";
}
return whatwgURL.serializeInteger(this._url.port);
}
set port(v) {
const copyURL = Object.assign({}, this._url);
if (copyURL.host === null || copyURL.cannotBeABaseURL || copyURL.scheme === "file") {
return;
}
whatwgURL.basicURLParse(v, { url: copyURL, stateOverride: "port" });
this._locationObjectSetterNavigate(copyURL);
}
get pathname() {
const url = this._url;
if (url.cannotBeABaseURL) {
return url.path[0];
}
return "/" + url.path.join("/");
}
set pathname(v) {
const copyURL = Object.assign({}, this._url);
if (copyURL.cannotBeABaseURL) {
return;
}
copyURL.path = [];
whatwgURL.basicURLParse(v, { url: copyURL, stateOverride: "path start" });
this._locationObjectSetterNavigate(copyURL);
}
get search() {
if (this._url.query === null || this._url.query === "") {
return "";
}
return "?" + this._url.query;
}
set search(v) {
const copyURL = Object.assign({}, this._url);
if (v === "") {
copyURL.query = null;
} else {
const input = v[0] === "?" ? v.substring(1) : v;
copyURL.query = "";
whatwgURL.basicURLParse(input, {
url: copyURL,
stateOverride: "query",
encodingOverride: this._relevantDocument.charset
});
}
this._locationObjectSetterNavigate(copyURL);
}
get hash() {
if (this._url.fragment === null || this._url.fragment === "") {
return "";
}
return "#" + this._url.fragment;
}
set hash(v) {
const copyURL = Object.assign({}, this._url);
if (copyURL.scheme === "javascript") {
return;
}
if (v === "") {
copyURL.fragment = null;
} else {
const input = v[0] === "#" ? v.substring(1) : v;
copyURL.fragment = "";
whatwgURL.basicURLParse(input, { url: copyURL, stateOverride: "fragment" });
}
this._locationObjectSetterNavigate(copyURL);
}
assign(url) {
// Should be entry settings object; oh well
const parsedURL = parseURLToResultingURLRecord(url, this._relevantDocument);
if (parsedURL === "failure") {
throw new DOMException(DOMException.SYNTAX_ERR, `Could not resolve the given string "${url}" relative to the ` +
`base URL "${this._relevantDocument.URL}"`);
}
this._locationObjectNavigate(parsedURL);
}
replace(url) {
// Should be entry settings object; oh well
const parsedURL = parseURLToResultingURLRecord(url, this._relevantDocument);
if (parsedURL === "failure") {
throw new DOMException(DOMException.SYNTAX_ERR, `Could not resolve the given string "${url}" relative to the ` +
`base URL "${this._relevantDocument.URL}"`);
}
this._locationObjectNavigate(parsedURL, { replacement: true });
}
reload() {
notImplemented("location.reload()", this._relevantDocument._defaultView);
}
};
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | 1 1 1 1 1 1 1 1 1 | "use strict";
const whatwgURL = require("whatwg-url");
const arrayEqual = require("array-equal");
const notImplemented = require("../../browser/not-implemented.js");
const HashChangeEvent = require("../generated/HashChangeEvent.js");
const PopStateEvent = require("../generated/PopStateEvent.js");
const idlUtils = require("../generated/utils");
exports.traverseHistory = (window, specifiedEntry, flags) => {
// Not spec compliant, just minimal. Lots of missing steps.
if (flags === undefined) {
flags = {};
}
const nonBlockingEvents = Boolean(flags.nonBlockingEvents);
const document = idlUtils.implForWrapper(window._document);
const currentEntry = window._sessionHistory[window._currentSessionHistoryEntryIndex];
if (currentEntry.title === undefined) {
currentEntry.title = document.title;
}
document._URL = specifiedEntry.url;
let hashChanged = false;
let oldURL;
let newURL;
if (specifiedEntry.url.fragment !== currentEntry.url.fragment) {
hashChanged = true;
oldURL = currentEntry.url;
newURL = specifiedEntry.url;
}
const state = specifiedEntry.stateObject; // TODO structured clone
document._history._state = state;
const stateChanged = specifiedEntry.document._history._latestEntry !== specifiedEntry;
specifiedEntry.document._history._latestEntry = specifiedEntry;
if (nonBlockingEvents) {
window.setTimeout(fireEvents, 0);
} else {
fireEvents();
}
function fireEvents() {
if (stateChanged) {
window.dispatchEvent(PopStateEvent.create(["popstate", {
bubbles: true,
cancelable: false,
state
}]));
}
if (hashChanged) {
window.dispatchEvent(HashChangeEvent.create(["hashchange", {
bubbles: true,
cancelable: false,
oldURL: whatwgURL.serializeURL(oldURL),
newURL: whatwgURL.serializeURL(newURL)
}]));
}
}
window._currentSessionHistoryEntryIndex = window._sessionHistory.indexOf(specifiedEntry);
};
exports.navigate = (window, newURL) => {
// This is NOT a spec-compliant implementation of navigation in any way. It implements a few selective steps that
// are nice for jsdom users, regarding hash changes. We could maybe implement javascript: URLs in the future, but
// the rest is too hard.
const document = idlUtils.implForWrapper(window._document);
const currentURL = document._URL;
if (newURL.scheme !== currentURL.scheme ||
newURL.username !== currentURL.username ||
newURL.password !== currentURL.password ||
newURL.host !== currentURL.host ||
newURL.port !== currentURL.port ||
!arrayEqual(newURL.path, currentURL.path) ||
newURL.query !== currentURL.query ||
// Omitted per spec: url.fragment !== this._url.fragment ||
newURL.cannotBeABaseURL !== currentURL.cannotBeABaseURL) {
notImplemented("navigation (except hash changes)", window);
return;
}
if (newURL.fragment !== currentURL.fragment) {
// https://html.spec.whatwg.org/#scroll-to-fragid
window._sessionHistory.splice(window._currentSessionHistoryEntryIndex + 1, Infinity);
document._history._clearHistoryTraversalTasks();
const newEntry = { document, url: newURL };
window._sessionHistory.push(newEntry);
exports.traverseHistory(window, newEntry, { nonBlockingEvents: true });
}
};
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| FormData-impl.js | 13.13% | (13 / 99) | 0% | (0 / 74) | 0% | (0 / 9) | 14.13% | (13 / 92) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | "use strict";
const idlUtils = require("../generated/utils");
const isFormElement = require("../generated/HTMLFormElement").isImpl;
const closest = require("../helpers/traversal").closest;
const isDisabled = require("../helpers/form-controls").isDisabled;
const isSubmittable = require("../helpers/form-controls").isSubmittable;
const isButton = require("../helpers/form-controls").isButton;
const normalizeToCRLF = require("../helpers/form-controls").normalizeToCRLF;
const Blob = require("../generated/Blob.js");
const File = require("../generated/File.js");
const conversions = require("webidl-conversions");
exports.implementation = class FormDataImpl {
constructor(args) {
this._entries = [];
if (args[0] !== undefined) {
if (!isFormElement(args[0])) {
throw new TypeError("First argument must undefined or a HTMLFormElement");
}
this._entries = constructTheFormDataSet(args[0]);
}
}
append(name, value, filename) {
// Handling this manually for now: https://github.com/jsdom/webidl2js/issues/29
if (!Blob.isImpl(value)) {
value = conversions.USVString(value);
}
const entry = createAnEntry(name, value, filename);
this._entries.push(entry);
}
delete(name) {
this._entries = this._entries.filter(entry => entry.name !== name);
}
get(name) {
const foundEntry = this._entries.find(entry => entry.name === name);
return foundEntry !== undefined ? foundEntry.value : null;
}
getAll(name) {
return this._entries.filter(entry => entry.name === name).map(entry => entry.value);
}
has(name) {
return this._entries.findIndex(entry => entry.name === name) !== -1;
}
set(name, value, filename) {
// Handling this manually for now: https://github.com/jsdom/webidl2js/issues/29
if (!Blob.isImpl(value)) {
value = conversions.USVString(value);
}
const entry = createAnEntry(name, value, filename);
const foundIndex = this._entries.findIndex(e => e.name === name);
if (foundIndex !== -1) {
this._entries[foundIndex] = entry;
this._entries = this._entries.filter((e, i) => e.name !== name || i === foundIndex);
} else {
this._entries.push(entry);
}
}
};
function createAnEntry(name, value, filename) {
const entry = { name };
// https://github.com/whatwg/xhr/issues/75
if (Blob.isImpl(value) && !File.isImpl(value)) {
const oldValue = value;
value = File.createImpl([
[],
"blob",
{ type: oldValue.type }
]);
// "representing the same bytes"
value._buffer = oldValue._buffer;
}
if (File.isImpl(value) && filename !== undefined) {
const oldValue = value;
value = File.createImpl([
[],
filename,
// spec makes no mention of `lastModified`; assume it is inherited
// (Chrome's behavior)
{ type: oldValue.type, lastModified: oldValue.lastModified }
]);
// "representing the same bytes"
value._buffer = oldValue._buffer;
}
entry.value = value;
return entry;
}
function constructTheFormDataSet(form, submitter) {
// https://html.spec.whatwg.org/multipage/forms.html#constructing-form-data-set
const controls = Array.prototype.filter.call(form.elements, isSubmittable); // submittable is a subset of listed
const formDataSet = [];
for (const fieldWrapper of controls) {
const field = idlUtils.implForWrapper(fieldWrapper);
if (closest(field, "datalist") !== null) {
continue;
}
if (isDisabled(field)) {
continue;
}
if (isButton(field) && field !== submitter) {
continue;
}
if (field.type === "checkbox" && field._checkedness === false) {
continue;
}
if (field.type === "radio" && field._checkedness === false) {
continue;
}
if (field.type !== "image" && (!field.hasAttribute("name") || field.getAttribute("name") === "")) {
continue;
}
if (field.localName === "object") { // in jsdom, no objects are "using a plugin"
continue;
}
const type = field.type;
// Omit special processing of <input type="image"> since so far we don't actually ever pass submitter
const nameAttr = field.getAttribute("name");
const name = nameAttr === null ? "" : nameAttr;
if (field.localName === "select") {
for (let i = 0; i < field.options.length; ++i) {
const option = idlUtils.implForWrapper(field.options[i]);
if (option._selectedness === true && !isDisabled(field)) {
formDataSet.push({ name, value: option.value, type });
}
}
} else if (field.localName === "input" && (type === "checkbox" || type === "radio")) {
const value = field.hasAttribute("value") ? field.getAttribute("value") : "on";
formDataSet.push({ name, value, type });
} else if (type === "file") {
for (let i = 0; i < field.files.length; ++i) {
formDataSet.push({ name, value: field.files.item(i), type });
}
if (field.files.length === 0) {
formDataSet.push({ name, value: "", type: "application/octet-stream" });
}
} /* skip plugins */ else {
formDataSet.push({ name, value: field._getValue(), type });
}
const dirname = field.getAttribute("dirname");
if (dirname !== null && dirname !== "") {
const dir = "ltr"; // jsdom does not (yet?) implement actual directionality
formDataSet.push({ name: dirname, value: dir, type: "direction" });
}
}
for (const entry of formDataSet) {
entry.name = conversions.USVString(normalizeToCRLF(entry.name));
if (entry.type !== "file" && entry.type !== "textarea") {
entry.value = normalizeToCRLF(entry.value);
}
if (entry.type !== "file") {
entry.value = conversions.USVString(entry.value);
}
}
return formDataSet;
}
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| DOMException.js | 65.22% | (15 / 23) | 0% | (0 / 4) | 0% | (0 / 1) | 63.64% | (14 / 22) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 1 1 30 1 1 21 1 1 1 1 1 1 21 1 | "use strict";
const addConstants = require("../utils").addConstants;
const table = require("./dom-exception-table.json"); // https://heycam.github.io/webidl/#idl-DOMException-error-names
// Precompute some stuff. Mostly unnecessary once we take care of the TODO below.
const namesWithCodes = Object.keys(table).filter(name => "legacyCodeValue" in table[name]);
const codesToNames = Object.create(null);
for (const name of namesWithCodes) {
codesToNames[table[name].legacyCodeValue] = name;
}
module.exports = DOMException;
// TODO: update constructor signature to match WebIDL spec
// See also https://github.com/heycam/webidl/pull/22 which isn't merged as of yet
function DOMException(code, message) {
const name = codesToNames[code];
if (message === undefined) {
message = table[name].description;
}
Error.call(this, message);
Object.defineProperty(this, "name", { value: name, writable: true, configurable: true, enumerable: false });
Object.defineProperty(this, "code", { value: code, writable: true, configurable: true, enumerable: false });
if (Error.captureStackTrace) {
Error.captureStackTrace(this, DOMException);
}
}
Object.setPrototypeOf(DOMException, Error);
Object.setPrototypeOf(DOMException.prototype, Error.prototype);
const constants = Object.create(null);
for (const name of namesWithCodes) {
constants[table[name].legacyCodeName] = table[name].legacyCodeValue;
}
addConstants(DOMException, constants);
|